From 9419526705fcc60555a686c3c91bc45d06efe739 Mon Sep 17 00:00:00 2001 From: kstranacher Date: Mon, 24 Jan 2011 13:51:25 +0000 Subject: git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@1194 d688527b-c9ab-4aba-bd8d-4036d912da1d --- .../moa/id/util/InOrderServletRequestWrapper.java | 36 +++++++++++++++------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'id/server/idserverlib/src/main/java') diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util/InOrderServletRequestWrapper.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util/InOrderServletRequestWrapper.java index 20f811e39..958ae646e 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util/InOrderServletRequestWrapper.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util/InOrderServletRequestWrapper.java @@ -106,9 +106,9 @@ public class InOrderServletRequestWrapper extends HttpServletRequestWrapper { bodyParameters = new Hashtable(); //Insert code for Query string parsing - String rawQuery = req.getQueryString(); + String rawQuery = req.getQueryString(); queryParameters = tokenize(queryParameters, queryParamOrder, rawQuery, DEFAULT_CHARACTER_ENCODING, true); - + //analyze HTTP Post body parameters if (req.getMethod().equalsIgnoreCase("POST")) { @@ -118,6 +118,7 @@ public class InOrderServletRequestWrapper extends HttpServletRequestWrapper { if (req.getContentType().equals("application/x-www-form-urlencoded")) { + try { bodyParameters = parsePostData(bodyParameters, req.getContentLength(), req.getInputStream(), enc); @@ -217,25 +218,38 @@ public class InOrderServletRequestWrapper extends HttpServletRequestWrapper { { String pair = (String) st.nextToken(); int pos = pair.indexOf('='); - if (pos == -1) - { - throw new IllegalArgumentException(); - } +// if (pos == -1) +// { +// throw new IllegalArgumentException(); +// } try { if (decode) { - key = URLDecoder.decode(pair.substring(0, pos), encoding); - val = URLDecoder.decode(pair.substring(pos + 1, pair.length()), encoding); + if (pos == -1) { // query is not a key=value pair, it is just a key + key = URLDecoder.decode(pair, encoding); + val = ""; // value is empty string + } + else { + key = URLDecoder.decode(pair.substring(0, pos), encoding); + val = URLDecoder.decode(pair.substring(pos + 1, pair.length()), encoding); + } } else { - key = pair.substring(0, pos); - val = pair.substring(pos + 1, pair.length()); + if (pos == -1) { // query is not a key=value pair, it is just a key + key = pair; + val = ""; // value is empty string + } + else { + key = pair.substring(0, pos); + val = pair.substring(pos + 1, pair.length()); + } } //Logger.debug("(" + Integer.toString(key.length()) + "=" + Integer.toString(pair.substring(0, pos).length()) + ")"+key+"|--|"+pair.substring(0, pos)); //Logger.debug("(" + Integer.toString(val.length()) + "=" + Integer.toString(pair.substring(pos + 1, pair.length()).length()) + ")"+val+"|--|"+pair.substring(pos + 1, pair.length())); } catch (Exception e) { - throw new IllegalArgumentException(); + Logger.error("Error encoding query", e); + throw new IllegalArgumentException(); } if (ht.containsKey(key)) { -- cgit v1.2.3