Merge in changes from SP (make sure pct-encoded is always two characters). 1.0
authorGeoffrey Sneddon <geoffers@gmail.com>
Tue Feb 05 17:38:44 2008 +0000 (2008-02-05)
changeset 37fac37a44041e
parent 36 84e28589009c
child 38 b4d02949e334
Merge in changes from SP (make sure pct-encoded is always two characters).
iri.php
     1.1 --- a/iri.php	Sun Nov 11 13:51:49 2007 +0000
     1.2 +++ b/iri.php	Tue Feb 05 17:38:44 2008 +0000
     1.3 @@ -380,7 +380,7 @@
     1.4  			if ($string[$position] === '%')
     1.5  			{
     1.6  				// If we have a pct-encoded section
     1.7 -				if ($position + 2 < $strlen && strspn($string, '0123456789ABCDEFabcdef', $position + 1, 2))
     1.8 +				if ($position + 2 < $strlen && strspn($string, '0123456789ABCDEFabcdef', $position + 1, 2) === 2)
     1.9  				{
    1.10  					// Get the the represented character
    1.11  					$chr = chr(hexdec(substr($string, $position + 1, 2)));
    1.12 @@ -419,7 +419,7 @@
    1.13  			// If we have an invalid character, change into its pct-encoded form
    1.14  			else
    1.15  			{
    1.16 -				$string = str_replace($string[$position], '%' . strtoupper(dechex(ord($string[$position]))), $string, $count);
    1.17 +				$string = str_replace($string[$position], '%' . sprintf('%%%02X', ord($string[$position])), $string, $count);
    1.18  				$strlen += 2 * $count;
    1.19  			}
    1.20  		}