Browse Source

Fixed bug that double escaped backslashes became three backslashes after parsing

pull/478/head
tbulle 11 years ago
parent
commit
6697216623
  1. 11
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionParser.cs

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

@ -96,12 +96,17 @@ namespace ICSharpCode.WpfDesign.XamlDom
if (text[pos] == '"' || text[pos] == '\'') { if (text[pos] == '"' || text[pos] == '\'') {
char quote = text[pos++]; char quote = text[pos++];
CheckNotEOF(); CheckNotEOF();
int lastBackslashPos = -1;
while (!(text[pos] == quote && text[pos-1] != '\\')) { while (!(text[pos] == quote && text[pos-1] != '\\')) {
char prev = text[pos-1]; int current = pos;
char c = text[pos++]; char c = text[pos++];
bool isEscapedBackslash = string.Concat(prev,c)=="\\\\"; //check if string is \\ and that the last backslash is not the previously saved char, ie that \\\\ does not become \\\ but just \\
if (c != '\\' || isEscapedBackslash) bool isEscapedBackslash = string.Concat(text[current-1],c)=="\\\\" && current-1 != lastBackslashPos;
if (c != '\\' || isEscapedBackslash){
b.Append(c); b.Append(c);
if(isEscapedBackslash)
lastBackslashPos = current;
}
CheckNotEOF(); CheckNotEOF();
} }
pos++; // consume closing quote pos++; // consume closing quote

Loading…
Cancel
Save