From: Thies C. Arntzen Date: Thu, 10 Feb 2000 09:44:22 +0000 (+0000) Subject: @- base64_decode() will decode POST data correct. (Thies) X-Git-Tag: BEFORE_SAPIFICATION_FEB_10_2000~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c59c663619346c2e9194cc8bd57e8b3e6371383d;p=php @- base64_decode() will decode POST data correct. (Thies) @ Patch submitted by: Turadg Aleahmad --- diff --git a/ext/standard/base64.c b/ext/standard/base64.c index cce691f0bf..d3ddbd17ff 100644 --- a/ext/standard/base64.c +++ b/ext/standard/base64.c @@ -96,6 +96,16 @@ unsigned char *php_base64_decode(const unsigned char *str, int length, int *ret_ /* run through the whole string, converting as we go */ while ((ch = *current++) != '\0') { if (ch == base64_pad) break; + + /* When Base64 gets POSTed, all pluses are interpreted as spaces. + This line changes them back. It's not exactly the Base64 spec, + but it is completely compatible with it (the spec says that + spaces are invalid). This will also save many people considerable + headache. - Turadg Aleahmad + */ + + if (ch == ' ') ch = '+'; + ch = reverse_table[ch]; if (ch < 0) continue;