Doc #60846 [NEW]: Warn that base64_encode needs urlencode in query string parameters
| From: | joeyadams3 dot 14159 at gmail dot com | Date: | Mon, 23 Jan 2012 06:03:35 +0000 |
| Subject: | Doc #60846 [NEW]: Warn that base64_encode needs urlencode in query string parameters | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-7813@lists.php.net to get a copy of this message | ||
From:
Operating system:
PHP version: Irrelevant
Package: *URL Functions
Bug Type: Documentation Problem
Bug description:Warn that base64_encode needs urlencode in query string parameters
Description:
------------
One of the characters used in MIME Base64 is '+', which is a special
character in URL query strings.
A common mistake is to use the result of base64_encode directly in a URL.
Example:
http://docs.joomla.org/index.php?title=How_do_you_redirect_users_after_a_successful_login%3F&oldid=36843
I even found some instances of this mistake in Joomla itself. I noticed it
while troubleshooting an issue where com_login would send the user to a
useless page saying "Welcome to the registered user area of our site."
I believe the documentation for base64_encode should warn about this. See
the test script for examples.
Test script:
---------------
<?php
$return = "http://localhost/~me";
// WRONG. This will be decoded server-side as "http://localhost/[Y"
$url = "login?return=" . base64_encode($return);
// Base64 must be URL-encoded when used in a URL, because it can contain
'+'
// characters.
$url = "login?return=" . urlencode(base64_encode($return));
?>
--
Edit bug report at https://bugs.php.net/bug.php?id=60846&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60846&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60846&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60846&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=60846&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60846&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=60846&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=60846&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=60846&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=60846&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=60846&r=support
Expected behavior: https://bugs.php.net/fix.php?id=60846&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=60846&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=60846&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=60846&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60846&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=60846&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=60846&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=60846&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=60846&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=60846&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=60846&r=mysqlcfg