Add escaping for Unicode characters that cause problems for browser JS eval

This commit is contained in:
chris.nokleberg
2009-01-20 06:11:40 +00:00
parent dc7f338698
commit 9e6002891b

View File

@@ -81,6 +81,15 @@ public class JSONObject extends HashMap{
case '/': case '/':
sb.append("\\/"); sb.append("\\/");
break; break;
case '\u0085': // Next Line
sb.append("\\u0085");
break;
case '\u2028': // Line Separator
sb.append("\\u2028");
break;
case '\u2029': // Paragraph Separator
sb.append("\\u2029");
break;
default: default:
if(ch>='\u0000' && ch<='\u001F'){ if(ch>='\u0000' && ch<='\u001F'){
String ss=Integer.toHexString(ch); String ss=Integer.toHexString(ch);