Correct bugs in JavaScript string escaping. Add JavaScriptConvertTest.
This commit is contained in:
@@ -34,6 +34,7 @@ using System.Security;
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
[assembly: InternalsVisibleTo("Newtonsoft.Json.Tests")]
|
||||
[assembly: AllowPartiallyTrustedCallers]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
|
||||
@@ -84,9 +84,13 @@ namespace Newtonsoft.Json.Utilities
|
||||
//case '\'':
|
||||
// StringUtils.WriteCharAsUnicode(writer, c);
|
||||
// break;
|
||||
case '\'':
|
||||
// only escape if this charater is being used as the delimiter
|
||||
writer.Write((delimiter == '\'') ? @"\'" : @"'");
|
||||
break;
|
||||
case '"':
|
||||
// only escape if this charater is being used as the delimiter
|
||||
writer.Write((delimiter == '"') ? "\\\"" : null);
|
||||
writer.Write((delimiter == '"') ? "\\\"" : @"""");
|
||||
break;
|
||||
default:
|
||||
if (c > '\u001f')
|
||||
@@ -130,8 +134,4 @@ namespace Newtonsoft.Json.Utilities
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user