Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 59 additions & 58 deletions core/src/main/java/com/bj58/argo/thirdparty/jetty/UrlEncoded.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,67 +190,68 @@ public static void decodeTo(String content, MultiMap<String> 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;i<content.length();i++)
if (content != null) {
synchronized(map)
{
char c = content.charAt(i);
switch (c)
String key = null;
String value = null;
int mark=-1;
boolean encoded=false;
for (int i=0;i<content.length();i++)
{
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;
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<content.length())
{
key = encoded
?decodeString(content,mark+1,content.length()-mark-1,charset)
:content.substring(mark+1);
if (key != null && key.length() > 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<content.length())
{
map.add(key,"");
key = encoded
?decodeString(content,mark+1,content.length()-mark-1,charset)
:content.substring(mark+1);
if (key != null && key.length() > 0)
{
map.add(key,"");
}
}
}
}
Expand Down Expand Up @@ -1017,4 +1018,4 @@ public static byte convertHexDigit( byte c )
throw new IllegalArgumentException("!hex "+c);
return b;
}
}
}