History

GSF.Core: Fixed issue in StringExtensions.ParseKeyValuePairs where certain character encodings would be decoded automatically by the parser.

StephenCWills committed 11 years ago

Commit 90c35bc1 parent 95638601 file · +9 −2Browse files

Showing the changes to Source/Libraries/GSF.Core/StringExtensions.cs (1 of 1 file). Show all

Unified · Split

Source/Libraries/GSF.Core/StringExtensions.cs+9−2
@@ -343,6 +343,7 @@ namespace GSF · 342 unmodified lines
343343 string escapedKeyValueDelimiter = keyValueDelimiter.RegexEncode();
344344 string escapedStartValueDelimiter = startValueDelimiter.RegexEncode();
345345 string escapedEndValueDelimiter = endValueDelimiter.RegexEncode();
346+ string backslashDelimiter = '\\'.RegexEncode();
346347 string[] elements;
347348 string key, unescapedValue;
348349 bool valueEscaped = false;
@@ -402,12 +403,17 @@ namespace GSF · 53 unmodified lines
402403 escapedValue.Append(escapedStartValueDelimiter);
403404 else if (character == endValueDelimiter)
404405 escapedValue.Append(escapedEndValueDelimiter);
406+ else if (character == '\\')
407+ escapedValue.Append(backslashDelimiter);
405408 else
406409 escapedValue.Append(character);
407410 }
408411 else
409412 {
410− escapedValue.Append(character);
413+ if (character == '\\')
414+ escapedValue.Append(backslashDelimiter);
415+ else
416+ escapedValue.Append(character);
411417 }
412418 }
413419
@@ -436,7 +442,8 @@ namespace GSF · 22 unmodified lines
436442 Replace(escapedParameterDelimiter, parameterDelimiter.ToString()).
437443 Replace(escapedKeyValueDelimiter, keyValueDelimiter.ToString()).
438444 Replace(escapedStartValueDelimiter, startValueDelimiter.ToString()).
439− Replace(escapedEndValueDelimiter, endValueDelimiter.ToString());
445+ Replace(escapedEndValueDelimiter, endValueDelimiter.ToString()).
446+ Replace(backslashDelimiter, "\\");
440447
441448 // Add key/value pair to dictionary
442449 if (ignoreDuplicateKeys)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t