Code Duplication    Length = 19-23 lines in 2 locations

wp-includes/class-requests.php 1 location

@@ 866-888 (lines=23) @@
863
	public static function compatible_gzinflate($gzData) {
864
		// Compressed data might contain a full zlib header, if so strip it for
865
		// gzinflate()
866
		if (substr($gzData, 0, 3) == "\x1f\x8b\x08") {
867
			$i = 10;
868
			$flg = ord(substr($gzData, 3, 1));
869
			if ($flg > 0) {
870
				if ($flg & 4) {
871
					list($xlen) = unpack('v', substr($gzData, $i, 2));
872
					$i = $i + 2 + $xlen;
873
				}
874
				if ($flg & 8) {
875
					$i = strpos($gzData, "\0", $i) + 1;
876
				}
877
				if ($flg & 16) {
878
					$i = strpos($gzData, "\0", $i) + 1;
879
				}
880
				if ($flg & 2) {
881
					$i = $i + 2;
882
				}
883
			}
884
			$decompressed = self::compatible_gzinflate(substr($gzData, $i));
885
			if (false !== $decompressed) {
886
				return $decompressed;
887
			}
888
		}
889
890
		// If the data is Huffman Encoded, we must first strip the leading 2
891
		// byte Huffman marker for gzinflate()

wp-includes/class-wp-http-encoding.php 1 location

@@ 102-120 (lines=19) @@
99
	public static function compatible_gzinflate($gzData) {
100
101
		// Compressed data might contain a full header, if so strip it for gzinflate().
102
		if ( substr($gzData, 0, 3) == "\x1f\x8b\x08" ) {
103
			$i = 10;
104
			$flg = ord( substr($gzData, 3, 1) );
105
			if ( $flg > 0 ) {
106
				if ( $flg & 4 ) {
107
					list($xlen) = unpack('v', substr($gzData, $i, 2) );
108
					$i = $i + 2 + $xlen;
109
				}
110
				if ( $flg & 8 )
111
					$i = strpos($gzData, "\0", $i) + 1;
112
				if ( $flg & 16 )
113
					$i = strpos($gzData, "\0", $i) + 1;
114
				if ( $flg & 2 )
115
					$i = $i + 2;
116
			}
117
			$decompressed = @gzinflate( substr($gzData, $i, -8) );
118
			if ( false !== $decompressed )
119
				return $decompressed;
120
		}
121
122
		// Compressed data from java.util.zip.Deflater amongst others.
123
		$decompressed = @gzinflate( substr($gzData, 2) );