Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit 6697216

Browse files
author
tbulle
committed
Fixed bug that double escaped backslashes became three backslashes after parsing
1 parent a6a9bfe commit 6697216

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionParser.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,17 @@ void MembernameOrString()
9696
if (text[pos] == '"' || text[pos] == '\'') {
9797
char quote = text[pos++];
9898
CheckNotEOF();
99+
int lastBackslashPos = -1;
99100
while (!(text[pos] == quote && text[pos-1] != '\\')) {
100-
char prev = text[pos-1];
101+
int current = pos;
101102
char c = text[pos++];
102-
bool isEscapedBackslash = string.Concat(prev,c)=="\\\\";
103-
if (c != '\\' || isEscapedBackslash)
103+
//check if string is \\ and that the last backslash is not the previously saved char, ie that \\\\ does not become \\\ but just \\
104+
bool isEscapedBackslash = string.Concat(text[current-1],c)=="\\\\" && current-1 != lastBackslashPos;
105+
if (c != '\\' || isEscapedBackslash){
104106
b.Append(c);
107+
if(isEscapedBackslash)
108+
lastBackslashPos = current;
109+
}
105110
CheckNotEOF();
106111
}
107112
pos++; // consume closing quote

0 commit comments

Comments
 (0)