From: post at kira-bianca dot eu
Operating system: Linux
PHP version: 5.4.11
Package: Scripting Engine problem
Bug Type: Bug
Bug description:rawurlencode appends char in conj.w. base64_decode when url-len
isn't div. by 3
Description:
------------
If I encode a URL with first the function base64_encode() and then with
rawurlencode() are appended in the URL may 1 or 2 characters "%3D".
If the length of the URL is divisible by 3, the result is okay.
If the division of the URL length by 3 a remainder of 1, to the url
"%3D%3D" attached
With a remainder of 2, "%3D" attached.
Test script:
---------------
$dom = "domain";
for ($i=0; $i<10; $dom.='x', $i++){
$url = "$dom.ldk";
$url_e = rawurlencode(base64_encode("$url"));
printf("%20s (len div 3 = %1d); encoded:%32s; decoded:%s\n",
$url,
strlen($url)%3,
$url_e,
rawurldecode(base64_decode($url_e)));
}
Expected result:
----------------
domain.ldk (len div 3 = 1); encoded:
ZG9tYWluLmxkaw%3D%3D; decoded:domain.ldk\nÃÃ
domainx.ldk (len div 3 = 2); encoded:
ZG9tYWlueC5sZGs%3D; decoded:domainx.ldk7
domainxx.ldk (len div 3 = 0); encoded:
ZG9tYWlueHgubGRr; decoded:domainxx.ldk
domainxxx.ldk (len div 3 = 1); encoded:
ZG9tYWlueHh4Lmxkaw%3D%3D; decoded:domainxxx.ldk\nÃÃ
domainxxxx.ldk (len div 3 = 2); encoded:
ZG9tYWlueHh4eC5sZGs%3D; decoded:domainxxxx.ldk7
domainxxxxx.ldk (len div 3 = 0); encoded:
ZG9tYWlueHh4eHgubGRr; decoded:domainxxxxx.ldk
domainxxxxxx.ldk (len div 3 = 1); encoded:
ZG9tYWlueHh4eHh4Lmxkaw%3D%3D; decoded:domainxxxxxx.ldk\nÃÃ
domainxxxxxxx.ldk (len div 3 = 2); encoded:
ZG9tYWlueHh4eHh4eC5sZGs%3D; decoded:domainxxxxxxx.ldk7
domainxxxxxxxx.ldk (len div 3 = 0); encoded:
ZG9tYWlueHh4eHh4eHgubGRr; decoded:domainxxxxxxxx.ldk
domainxxxxxxxxx.ldk (len div 3 = 1);
encoded:ZG9tYWlueHh4eHh4eHh4Lmxkaw%3D%3D; decoded:domainxxxxxxxxx.ldk\nÃÃ
--
Edit bug report at https://bugs.php.net/bug.php?id=64131&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=64131&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=64131&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=64131&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=64131&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=64131&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64131&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=64131&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=64131&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=64131&r=support
Expected behavior: https://bugs.php.net/fix.php?id=64131&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=64131&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=64131&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=64131&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64131&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=64131&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=64131&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=64131&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64131&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64131&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=64131&r=mysqlcfg