[cpp-sp COMMIT] in /branches/REL_2/shibsp: handler/impl/AbstractHandler.cpp impl/XMLRequestMapper.cpp util/CGIParser....

noreply at shibboleth.net noreply at shibboleth.net
Thu Sep 29 05:04:45 BST 2011


Author: scantor
Date: Thu Sep 29 05:04:45 2011
New Revision: 3525

URL: http://svn.shibboleth.net/view/cpp-sp?rev=3525&view=rev
Log:
https://issues.shibboleth.net/jira/browse/SSPCPP-335

Modified:
    branches/REL_2/shibsp/handler/impl/AbstractHandler.cpp
    branches/REL_2/shibsp/impl/XMLRequestMapper.cpp
    branches/REL_2/shibsp/util/CGIParser.cpp
    branches/REL_2/shibsp/util/CGIParser.h

Modified: branches/REL_2/shibsp/handler/impl/AbstractHandler.cpp
URL: http://svn.shibboleth.net/view/cpp-sp/branches/REL_2/shibsp/handler/impl/AbstractHandler.cpp?rev=3525&r1=3524&r2=3525&view=diff
==============================================================================
--- branches/REL_2/shibsp/handler/impl/AbstractHandler.cpp (original)
+++ branches/REL_2/shibsp/handler/impl/AbstractHandler.cpp Thu Sep 29 05:04:45 2011
@@ -795,7 +795,7 @@
 DDF AbstractHandler::getPostData(const Application& application, const HTTPRequest& request) const
 {
     string contentType = request.getContentType();
-    if (contentType.compare("application/x-www-form-urlencoded") == 0) {
+    if (contentType.find("application/x-www-form-urlencoded") != string::npos) {
         const PropertySet* props=application.getPropertySet("Sessions");
         pair<bool,unsigned int> plimit = props ? props->getUnsignedInt("postLimit") : pair<bool,unsigned int>(false,0);
         if (!plimit.first)

Modified: branches/REL_2/shibsp/impl/XMLRequestMapper.cpp
URL: http://svn.shibboleth.net/view/cpp-sp/branches/REL_2/shibsp/impl/XMLRequestMapper.cpp?rev=3525&r1=3524&r2=3525&view=diff
==============================================================================
--- branches/REL_2/shibsp/impl/XMLRequestMapper.cpp (original)
+++ branches/REL_2/shibsp/impl/XMLRequestMapper.cpp Thu Sep 29 05:04:45 2011
@@ -28,6 +28,7 @@
 #include "AccessControl.h"
 #include "RequestMapper.h"
 #include "SPRequest.h"
+#include "util/CGIParser.h"
 #include "util/DOMPropertySet.h"
 #include "util/SPConstants.h"
 
@@ -450,23 +451,24 @@
     }
 
     // Finally, check for query string matches. This is another "unrolled" recursive descent in a loop.
-    // For now, only check if the method is GET, to avoid consuming POST data. Will need to revise the
-    // CGIParser API to fix this.
-    if (strcmp(request.getMethod(), "POST")) {
+    // To avoid consuming any POST data, we use a dedicated CGIParser.
+    if (!o->m_queries.empty()) {
         bool descended;
+        CGIParser cgi(request, true);
         do {
             descended = false;
             for (vector< pair< pair<string,RegularExpression*>,Override*> >::const_iterator q = o->m_queries.begin(); !descended && q != o->m_queries.end(); ++q) {
-                vector<const char*> vals;
-                if (request.getParameters(q->first.first.c_str(), vals)) {
+                pair<CGIParser::walker,CGIParser::walker> vals = cgi.getParameters(q->first.first.c_str());
+                if (vals.first != vals.second) {
                     if (q->first.second) {
                         // We have to match one of the values.
-                        for (vector<const char*>::const_iterator v = vals.begin(); v != vals.end(); ++v) {
-                            if (q->first.second->matches(*v)) {
+                        while (vals.first != vals.second) {
+                            if (q->first.second->matches(vals.first->second)) {
                                 o = q->second;
                                 descended = true;
                                 break;
                             }
+                            ++vals.first;
                         }
                     }
                     else {

Modified: branches/REL_2/shibsp/util/CGIParser.cpp
URL: http://svn.shibboleth.net/view/cpp-sp/branches/REL_2/shibsp/util/CGIParser.cpp?rev=3525&r1=3524&r2=3525&view=diff
==============================================================================
--- branches/REL_2/shibsp/util/CGIParser.cpp (original)
+++ branches/REL_2/shibsp/util/CGIParser.cpp Thu Sep 29 05:04:45 2011
@@ -35,26 +35,73 @@
 using namespace xmltooling;
 using namespace std;
 
+namespace {
+    /* Parsing routines modified from NCSA source. */
+    char* makeword(char *line, char stop)
+    {
+        int x = 0,y;
+        char *word = (char *) malloc(sizeof(char) * (strlen(line) + 1));
 
-CGIParser::CGIParser(const HTTPRequest& request)
+        for(x=0;((line[x]) && (line[x] != stop));x++)
+            word[x] = line[x];
+
+        word[x] = '\0';
+        if(line[x])
+            ++x;
+        y=0;
+
+        while(line[x])
+          line[y++] = line[x++];
+        line[y] = '\0';
+        return word;
+    }
+
+    char* fmakeword(char stop, size_t *cl, const char** ppch)
+    {
+        int wsize;
+        char *word;
+        int ll;
+
+        wsize = 1024;
+        ll=0;
+        word = (char *) malloc(sizeof(char) * (wsize + 1));
+
+        while(1)
+        {
+            word[ll] = *((*ppch)++);
+            if(ll==wsize-1)
+            {
+                word[ll+1] = '\0';
+                wsize+=1024;

[... 168 lines stripped ...]


More information about the commits mailing list