From 8b30a181ba539e8081ec63d3c875f6df525b150d Mon Sep 17 00:00:00 2001 From: hzieept Date: Thu, 9 May 2013 23:15:04 +0800 Subject: [PATCH] Update UrlEncoded.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit post提交时,遇到url如http://ip/a/b/,没有?以及参数情况.ArgoRequest.queryStrings()中调用super.getQueryString()时会返回null,所以要在UrlEncoded中加卫语句 --- .../argo/thirdparty/jetty/UrlEncoded.java | 117 +++++++++--------- 1 file changed, 59 insertions(+), 58 deletions(-) diff --git a/core/src/main/java/com/bj58/argo/thirdparty/jetty/UrlEncoded.java b/core/src/main/java/com/bj58/argo/thirdparty/jetty/UrlEncoded.java index 9850877..12b5ced 100644 --- a/core/src/main/java/com/bj58/argo/thirdparty/jetty/UrlEncoded.java +++ b/core/src/main/java/com/bj58/argo/thirdparty/jetty/UrlEncoded.java @@ -190,67 +190,68 @@ public static void decodeTo(String content, MultiMap map, Charset charse { if (charset==null) charset=ENCODING; - - synchronized(map) - { - String key = null; - String value = null; - int mark=-1; - boolean encoded=false; - for (int i=0;i0) - { - map.add(value,""); - } - key = null; - value=null; - if (maxKeys>0 && map.size()>maxKeys) - throw new IllegalStateException("Form too many keys"); - break; - case '=': - if (key!=null) + char c = content.charAt(i); + switch (c) + { + case '&': + int l=i-mark-1; + value = l==0?"": + (encoded?decodeString(content,mark+1,l,charset):content.substring(mark+1,i)); + mark=i; + encoded=false; + if (key != null) + { + map.add(key,value); + } + else if (value!=null&&value.length()>0) + { + map.add(value,""); + } + key = null; + value=null; + if (maxKeys>0 && map.size()>maxKeys) + throw new IllegalStateException("Form too many keys"); break; - key = encoded?decodeString(content,mark+1,i-mark-1,charset):content.substring(mark+1,i); - mark=i; - encoded=false; - break; - case '+': - encoded=true; - break; - case '%': - encoded=true; - break; - } - } - - if (key != null) - { - int l=content.length()-mark-1; - value = l==0?"":(encoded?decodeString(content,mark+1,l,charset):content.substring(mark+1)); - map.add(key,value); - } - else if (mark 0) + case '=': + if (key!=null) + break; + key = encoded?decodeString(content,mark+1,i-mark-1,charset):content.substring(mark+1,i); + mark=i; + encoded=false; + break; + case '+': + encoded=true; + break; + case '%': + encoded=true; + break; + } + } + + if (key != null) + { + int l=content.length()-mark-1; + value = l==0?"":(encoded?decodeString(content,mark+1,l,charset):content.substring(mark+1)); + map.add(key,value); + } + else if (mark 0) + { + map.add(key,""); + } } } } @@ -1017,4 +1018,4 @@ public static byte convertHexDigit( byte c ) throw new IllegalArgumentException("!hex "+c); return b; } -} \ No newline at end of file +}