|
9 | 9 | using System.Globalization; |
10 | 10 | using System.Collections; |
11 | 11 | using System.Collections.Generic; |
| 12 | +using System.Text.RegularExpressions; |
12 | 13 | using System.Xml; |
13 | 14 | using System.Xml.Linq; |
14 | 15 | using System.Xml.XmlDiff; |
@@ -3418,8 +3419,12 @@ public void WriteCDataWithTwoClosingBrackets_5() |
3418 | 3419 | Exception exception = AssertExtensions.Throws<ArgumentException>(null, () => MoveToFirstElement(reader).ReadOuterXml()); |
3419 | 3420 | if (!PlatformDetection.IsNetNative) // .Net Native toolchain optimizes away Exception messages |
3420 | 3421 | { |
3421 | | - string expectedMsg = "Cannot have ']]>' inside an XML CDATA block."; |
3422 | | - Assert.Equal(expectedMsg, exception.Message); |
| 3422 | + // \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi |
| 3423 | + // \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf |
| 3424 | + // \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po |
| 3425 | + Assert.True(Regex.IsMatch(exception.Message, @"[\p{Pi}\p{Po}]" + Regex.Escape("]]>") + @"[\p{Pf}\p{Po}]")); |
| 3426 | + Assert.True(Regex.IsMatch(exception.Message, @"\b" + "XML" + @"\b")); |
| 3427 | + Assert.True(Regex.IsMatch(exception.Message, @"\b" + "CDATA" + @"\b")); |
3423 | 3428 | } |
3424 | 3429 | } |
3425 | 3430 | } |
@@ -3612,8 +3617,13 @@ public void WriteCommentWithDoubleHyphensInValue() |
3612 | 3617 | Exception exception = AssertExtensions.Throws<ArgumentException>(null, () => MoveToFirstElement(reader).ReadOuterXml()); |
3613 | 3618 | if (!PlatformDetection.IsNetNative) // .Net Native toolchain optimizes away Exception messages |
3614 | 3619 | { |
3615 | | - string expectedMsg = "An XML comment cannot contain '--', and '-' cannot be the last character."; |
3616 | | - Assert.Equal(expectedMsg, exception.Message); |
| 3620 | + // \b word boundary |
| 3621 | + // \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi |
| 3622 | + // \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf |
| 3623 | + // \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po |
| 3624 | + Assert.True(Regex.IsMatch(exception.Message, @"\b" + "XML" + @"\b")); |
| 3625 | + Assert.True(Regex.IsMatch(exception.Message, @"[\p{Pi}\p{Po}]" + Regex.Escape("--") + @"[\p{Pf}\p{Po}]")); |
| 3626 | + Assert.True(Regex.IsMatch(exception.Message, @"[\p{Pi}\p{Po}]" + Regex.Escape("-") + @"[\p{Pf}\p{Po}]")); |
3617 | 3627 | } |
3618 | 3628 | } |
3619 | 3629 | } |
@@ -4215,8 +4225,12 @@ public void IncludePIEndTagAsPartOfTextValue() |
4215 | 4225 | Exception exception = AssertExtensions.Throws<ArgumentException>(null, () => MoveToFirstElement(reader).ReadOuterXml()); |
4216 | 4226 | if (!PlatformDetection.IsNetNative) // .Net Native toolchain optimizes away Exception messages |
4217 | 4227 | { |
4218 | | - string expectedMsg = "Cannot have '?>' inside an XML processing instruction."; |
4219 | | - Assert.Equal(expectedMsg, exception.Message); |
| 4228 | + // \b word boundary |
| 4229 | + // \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi |
| 4230 | + // \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf |
| 4231 | + // \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po |
| 4232 | + Assert.True(Regex.IsMatch(exception.Message, @"[\p{Pi}\p{Po}]" + Regex.Escape("?>") + @"[\p{Pf}\p{Po}]")); |
| 4233 | + Assert.True(Regex.IsMatch(exception.Message, @"\b" + "XML" + @"\b")); |
4220 | 4234 | } |
4221 | 4235 | } |
4222 | 4236 | } |
|
0 commit comments