jenkins-bot has submitted this change and it was merged.

Change subject: Add methods to get raw request in WebRequest
......................................................................


Add methods to get raw request in WebRequest

Make it possible to get the raw parameters given to the request, with
no escaping. This is needed for features like OAuth, where a signature
is calculated over the parameters to verify their integrity and source.

FauxRequest is extended so the original request doesn't pollute the
fake one. This could be extended so "raw" values could be set and used,
but there isn't a use case for that yet, so it's not done here.

Change-Id: I8710844f21d21cbbf28517b0cc25b0713b506bee
---
M includes/WebRequest.php
1 file changed, 62 insertions(+), 0 deletions(-)

Approvals:
  Parent5446: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/WebRequest.php b/includes/WebRequest.php
index dbd0740..80881c9 100644
--- a/includes/WebRequest.php
+++ b/includes/WebRequest.php
@@ -569,6 +569,44 @@
        }
 
        /**
+        * Return the contents of the Query with no decoding. Use when you need 
to
+        * know exactly what was sent, e.g. for an OAuth signature over the 
elements.
+        *
+        * @return String
+        */
+       public function getRawQueryString() {
+               return $_SERVER['QUERY_STRING'];
+       }
+
+       /**
+        * Return the contents of the POST with no decoding. Use when you need 
to
+        * know exactly what was sent, e.g. for an OAuth signature over the 
elements.
+        *
+        * @return String
+        */
+       public function getRawPostString() {
+               if ( !$this->wasPosted() ) {
+                       return '';
+               }
+               return $this->getRawInput();
+       }
+
+       /**
+        * Return the raw request body, with no processing. Cached since some 
methods
+        * disallow reading the stream more than once. As stated in the php 
docs, this
+        * does not work with enctype="multipart/form-data".
+        *
+        * @return String
+        */
+       public function getRawInput() {
+               static $input = false;
+               if ( $input === false ) {
+                       $input = file_get_contents( 'php://input' );
+               }
+               return $input;
+       }
+
+       /**
         * Get the HTTP method used for this request.
         *
         * @return String
@@ -1392,6 +1430,30 @@
        }
 
        /**
+        * FauxRequests shouldn't depend on raw request data (but that could be 
implemented here)
+        * @return String
+        */
+       public function getRawQueryString() {
+               return '';
+       }
+
+       /**
+        * FauxRequests shouldn't depend on raw request data (but that could be 
implemented here)
+        * @return String
+        */
+       public function getRawPostString() {
+               return '';
+       }
+
+       /**
+        * FauxRequests shouldn't depend on raw request data (but that could be 
implemented here)
+        * @return String
+        */
+       public function getRawInput() {
+               return '';
+       }
+
+       /**
         * @param array $extWhitelist
         * @return bool
         */

-- 
To view, visit https://gerrit.wikimedia.org/r/70747
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I8710844f21d21cbbf28517b0cc25b0713b506bee
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: CSteipp <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Daniel Friesen <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to