Correct bugs in JavaScript string escaping. Add JavaScriptConvertTest.

This commit is contained in:
JamesNK
2007-09-10 11:01:42 +00:00
parent e65bc2becd
commit 487dc81251
5 changed files with 99 additions and 6 deletions
@@ -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
}
}
}
}
}