MediaWiki REL1_32
EasyDeflate.php
Go to the documentation of this file.
1<?php
25
33 public static function isDeflated( $data ) {
34 return substr( $data, 0, 11 ) === 'rawdeflate,';
35 }
36
56 public static function inflate( $data ) {
57 if ( !self::isDeflated( $data ) ) {
58 throw new InvalidArgumentException( 'Data does not begin with deflated prefix' );
59 }
60 $deflated = base64_decode( substr( $data, 11 ), true );
61 if ( $deflated === false ) {
62 return StatusValue::newFatal( 'easydeflate-invaliddeflate' );
63 }
64 Wikimedia\suppressWarnings();
65 $inflated = gzinflate( $deflated );
66 Wikimedia\restoreWarnings();
67 if ( $inflated === false ) {
68 return StatusValue::newFatal( 'easydeflate-invaliddeflate' );
69 }
70 return StatusValue::newGood( $inflated );
71 }
72}
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...
static inflate( $data)
For content that has been compressed with deflate in the client, try to uncompress it with inflate.
static isDeflated( $data)
Whether the content is deflated.