summaryrefslogtreecommitdiff
path: root/BCT
diff options
context:
space:
mode:
authorGravatar qadeer <qadeer@microsoft.com>2012-03-11 13:06:55 -0700
committerGravatar qadeer <qadeer@microsoft.com>2012-03-11 13:06:55 -0700
commit7949e676b1c3c8b25cc88a884dfeb25d58629227 (patch)
tree090b64da25ec836e8d71bc76aa6bbfc7cf59e7f4 /BCT
parent02a38fe3bf1fad952dddcf46117be3931cf932f1 (diff)
further sanitization of string in :value attribute
Diffstat (limited to 'BCT')
-rw-r--r--BCT/BytecodeTranslator/Heap.cs3
-rw-r--r--BCT/BytecodeTranslator/Sink.cs2
2 files changed, 3 insertions, 2 deletions
diff --git a/BCT/BytecodeTranslator/Heap.cs b/BCT/BytecodeTranslator/Heap.cs
index aaed79e4..731d5e66 100644
--- a/BCT/BytecodeTranslator/Heap.cs
+++ b/BCT/BytecodeTranslator/Heap.cs
@@ -314,8 +314,7 @@ namespace BytecodeTranslator {
#endregion
#region Parse the declarations
- var ms = new MemoryStream(ASCIIEncoding.UTF8.GetBytes(preludeText.ToString()));
- int errorCount = Bpl.Parser.Parse(ms, "foo", new List<string>(), out prelude);
+ int errorCount = Bpl.Parser.Parse(preludeText.ToString(), "foo", out prelude);
if (prelude == null || errorCount > 0) {
prelude = null;
return false;
diff --git a/BCT/BytecodeTranslator/Sink.cs b/BCT/BytecodeTranslator/Sink.cs
index 7a1abc07..d89f1bfd 100644
--- a/BCT/BytecodeTranslator/Sink.cs
+++ b/BCT/BytecodeTranslator/Sink.cs
@@ -331,6 +331,8 @@ namespace BytecodeTranslator {
var tident = new Bpl.TypedIdent(tok, name, t);
c = new Bpl.Constant(tok, tident, true);
str = str.Replace("\n", "\\n");
+ str = str.Replace("\r", "\\r");
+ str = str.Replace("\"", "\u0022");
var attrib = new Bpl.QKeyValue(Bpl.Token.NoToken, "value", new List<object> { str, }, null);
c.Attributes = attrib;
this.declaredStringConstants.Add(str, c);