diff options
author | Marek Safar <marek.safar@gmail.com> | 2016-03-14 14:35:04 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2016-03-14 14:36:02 +0300 |
commit | ed05a531e81cb3ba2289082bcce9ad76db6727c2 (patch) | |
tree | 0f674102ed1bd60cfd73e28d1831b714bb68e6a2 /mcs/class/System.Net.Http | |
parent | f9f9746f9837742c4cf04c51ff6557dd82642fc7 (diff) |
[system.net.http] The backslash character may be used as a single-character quoting mechanism within quoted-string. Fixes #39569
Diffstat (limited to 'mcs/class/System.Net.Http')
-rw-r--r-- | mcs/class/System.Net.Http/System.Net.Http.Headers/Lexer.cs | 14 | ||||
-rw-r--r-- | mcs/class/System.Net.Http/Test/System.Net.Http.Headers/EntityTagHeaderValueTest.cs | 6 |
2 files changed, 20 insertions, 0 deletions
diff --git a/mcs/class/System.Net.Http/System.Net.Http.Headers/Lexer.cs b/mcs/class/System.Net.Http/System.Net.Http.Headers/Lexer.cs index 694bf6e56e6..71df86877c6 100644 --- a/mcs/class/System.Net.Http/System.Net.Http.Headers/Lexer.cs +++ b/mcs/class/System.Net.Http/System.Net.Http.Headers/Lexer.cs @@ -313,6 +313,20 @@ namespace System.Net.Http.Headers start = pos - 1; while (pos < s.Length) { ch = s [pos++]; + + // + // The backslash character ("\") MAY be used as a single-character + // quoting mechanism only within quoted-string + // + if (ch == '\\') { + if (pos + 1 < s.Length) { + ++pos; + continue; + } + + break; + } + if (ch == '"') { ttype = Token.Type.QuotedString; break; diff --git a/mcs/class/System.Net.Http/Test/System.Net.Http.Headers/EntityTagHeaderValueTest.cs b/mcs/class/System.Net.Http/Test/System.Net.Http.Headers/EntityTagHeaderValueTest.cs index 78c267072bf..5099ce42551 100644 --- a/mcs/class/System.Net.Http/Test/System.Net.Http.Headers/EntityTagHeaderValueTest.cs +++ b/mcs/class/System.Net.Http/Test/System.Net.Http.Headers/EntityTagHeaderValueTest.cs @@ -74,6 +74,12 @@ namespace MonoTests.System.Net.Http.Headers Assert.AreEqual ("\"mm\"", res.Tag, "#11"); Assert.IsTrue (res.IsWeak, "#12"); Assert.AreEqual ("W/\"mm\"", res.ToString (), "#13"); + + + res = EntityTagHeaderValue.Parse ("\"\\\"123\\\"\""); + Assert.AreEqual ("\"\\\"123\\\"\"", res.Tag, "#21"); + Assert.IsFalse (res.IsWeak, "#22"); + Assert.AreEqual ("\"\\\"123\\\"\"", res.ToString (), "#23"); } [Test] |