Code Duplication    Length = 3-4 lines in 12 locations

src/wp-includes/ID3/module.tag.id3v2.php 12 locations

@@ 629-632 (lines=4) @@
626
			$frame_offset = 0;
627
			$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
628
			$frame_textencoding_terminator = $this->TextEncodingTerminatorLookup($frame_textencoding);
629
			if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
630
				$info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
631
				$frame_textencoding_terminator = "\x00";
632
			}
633
			$frame_terminatorpos = strpos($parsedFrame['data'], $frame_textencoding_terminator, $frame_offset);
634
			if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($frame_textencoding_terminator), 1)) === 0) {
635
				$frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00
@@ 666-668 (lines=3) @@
663
664
			$frame_offset = 0;
665
			$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
666
			if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
667
				$info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
668
			}
669
670
			$parsedFrame['data'] = (string) substr($parsedFrame['data'], $frame_offset);
671
@@ 722-725 (lines=4) @@
719
			$frame_offset = 0;
720
			$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
721
			$frame_textencoding_terminator = $this->TextEncodingTerminatorLookup($frame_textencoding);
722
			if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
723
				$info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
724
				$frame_textencoding_terminator = "\x00";
725
			}
726
			$frame_terminatorpos = strpos($parsedFrame['data'], $frame_textencoding_terminator, $frame_offset);
727
			if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($frame_textencoding_terminator), 1)) === 0) {
728
				$frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00
@@ 785-787 (lines=3) @@
782
783
			$frame_offset = 0;
784
			$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
785
			if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
786
				$info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
787
			}
788
			$parsedFrame['encodingid'] = $frame_textencoding;
789
			$parsedFrame['encoding']   = $this->TextEncodingNameLookup($parsedFrame['encodingid']);
790
			$parsedFrame['data_raw']   = (string) substr($parsedFrame['data'], $frame_offset);
@@ 963-966 (lines=4) @@
960
			$frame_offset = 0;
961
			$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
962
			$frame_textencoding_terminator = $this->TextEncodingTerminatorLookup($frame_textencoding);
963
			if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
964
				$info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
965
				$frame_textencoding_terminator = "\x00";
966
			}
967
			$frame_language = substr($parsedFrame['data'], $frame_offset, 3);
968
			$frame_offset += 3;
969
			$frame_terminatorpos = strpos($parsedFrame['data'], $frame_textencoding_terminator, $frame_offset);
@@ 1011-1014 (lines=4) @@
1008
			$frame_offset = 0;
1009
			$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
1010
			$frame_textencoding_terminator = $this->TextEncodingTerminatorLookup($frame_textencoding);
1011
			if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
1012
				$info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
1013
				$frame_textencoding_terminator = "\x00";
1014
			}
1015
			$frame_language = substr($parsedFrame['data'], $frame_offset, 3);
1016
			$frame_offset += 3;
1017
			$parsedFrame['timestampformat'] = ord(substr($parsedFrame['data'], $frame_offset++, 1));
@@ 1071-1074 (lines=4) @@
1068
				$frame_offset = 0;
1069
				$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
1070
				$frame_textencoding_terminator = $this->TextEncodingTerminatorLookup($frame_textencoding);
1071
				if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
1072
					$info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
1073
					$frame_textencoding_terminator = "\x00";
1074
				}
1075
				$frame_language = substr($parsedFrame['data'], $frame_offset, 3);
1076
				$frame_offset += 3;
1077
				$frame_terminatorpos = strpos($parsedFrame['data'], $frame_textencoding_terminator, $frame_offset);
@@ 1343-1346 (lines=4) @@
1340
			$frame_offset = 0;
1341
			$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
1342
			$frame_textencoding_terminator = $this->TextEncodingTerminatorLookup($frame_textencoding);
1343
			if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
1344
				$info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
1345
				$frame_textencoding_terminator = "\x00";
1346
			}
1347
1348
			if ($id3v2_majorversion == 2 && strlen($parsedFrame['data']) > $frame_offset) {
1349
				$frame_imagetype = substr($parsedFrame['data'], $frame_offset, 3);
@@ 1484-1487 (lines=4) @@
1481
			$frame_offset = 0;
1482
			$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
1483
			$frame_textencoding_terminator = $this->TextEncodingTerminatorLookup($frame_textencoding);
1484
			if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
1485
				$info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
1486
				$frame_textencoding_terminator = "\x00";
1487
			}
1488
			$frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset);
1489
			$frame_mimetype = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
1490
			if (ord($frame_mimetype) === 0) {
@@ 1685-1687 (lines=3) @@
1682
1683
			$frame_offset = 0;
1684
			$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
1685
			if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
1686
				$info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
1687
			}
1688
			$frame_language = substr($parsedFrame['data'], $frame_offset, 3);
1689
			$frame_offset += 3;
1690
			$parsedFrame['language']     = $frame_language;
@@ 1712-1714 (lines=3) @@
1709
1710
			$frame_offset = 0;
1711
			$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
1712
			if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
1713
				$info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
1714
			}
1715
			$parsedFrame['encodingid'] = $frame_textencoding;
1716
			$parsedFrame['encoding']   = $this->TextEncodingNameLookup($frame_textencoding);
1717
@@ 1753-1756 (lines=4) @@
1750
			$frame_offset = 0;
1751
			$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
1752
			$frame_textencoding_terminator = $this->TextEncodingTerminatorLookup($frame_textencoding);
1753
			if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
1754
				$info['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
1755
				$frame_textencoding_terminator = "\x00";
1756
			}
1757
1758
			$frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset);
1759
			$frame_pricestring = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);