Improved http_build_query (fixes reCAPTCHA)
authorSascha Greuel <sascha@softcreatr.de>
Tue, 2 Jul 2013 21:28:37 +0000 (23:28 +0200)
committerSascha Greuel <sascha@softcreatr.de>
Tue, 2 Jul 2013 21:28:37 +0000 (23:28 +0200)
As of PHP 5.3, the default seperator of http_build_query is
arg_separator.input, which is in some cases "&amp". This may cause some
unexpected problems i.e. reCAPTCHA doesn't work as intended.

wcfsetup/install/files/lib/util/HTTPRequest.class.php

index f5a946660d47677b2351ed7d006768873b6b2bd3..3c163a4fa549ba7f0a7368a6a0da25b068f57945 100644 (file)
@@ -105,7 +105,7 @@ final class HTTPRequest {
                $this->addHeader('Accept', '*/*');
                $this->addHeader('Accept-Language', WCF::getLanguage()->getFixedLanguageCode());
                if ($this->options['method'] !== 'GET') {
-                       $this->addHeader('Content-length', strlen(http_build_query($this->postParameters)));
+                       $this->addHeader('Content-length', strlen(http_build_query($this->postParameters, '', '&')));
                        $this->addHeader('Content-Type', 'application/x-www-form-urlencoded');
                }
                if (isset($this->options['auth'])) {
@@ -153,7 +153,7 @@ final class HTTPRequest {
                }
                $request .= "\r\n";
                // add post parameters
-               if ($this->options['method'] !== 'GET') $request .= http_build_query($this->postParameters)."\r\n\r\n";
+               if ($this->options['method'] !== 'GET') $request .= http_build_query($this->postParameters, '', '&')."\r\n\r\n";
                $remoteFile->puts($request);
                
                $inHeader = true;