Commit a929dae3 authored by Frédéric Wang's avatar Frédéric Wang Committed by Commit Bot

[mathml] Use ASCII case-insensitiveness to validate mathsize and dir

The mathsize and dir attributes are defined modulo ASCII
case-insensitive equivalence and are mapped to CSS font-size and
direction properties [1] [2]. Since the CSS keywords are themselves
defined modulo ASCII case-insensitive equivalence [3], there is not need
to filter out other (Unicode) case-insensitive equivalent keywords
(e.g. "ſmall") in the MathML Code, they will be rejected by the CSS
parser.

This CL replaces DeprecatedEqualIgnoringCase with EqualIgnoringASCIICase
and adds tests to ensure that (Unicode) case-insensitive equivalent
strings remain disallowed.

[1] https://mathml-refresh.github.io/mathml-core/#global-attributes
[2] https://github.com/mathml-refresh/mathml/issues/178
[3] https://www.w3.org/TR/css-values-4/#keywords

Bug: 6606
Bug: 627682
Change-Id: Ice84368c8cc7e8fff9faccb454c23fad87b99d59
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1970615Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Commit-Queue: Frédéric Wang <fwang@igalia.com>
Cr-Commit-Position: refs/heads/master@{#725481}
parent 2e8365c7
...@@ -19,17 +19,17 @@ MathMLElement::MathMLElement(const QualifiedName& tagName, ...@@ -19,17 +19,17 @@ MathMLElement::MathMLElement(const QualifiedName& tagName,
MathMLElement::~MathMLElement() {} MathMLElement::~MathMLElement() {}
static inline bool IsValidDirAttribute(const AtomicString& value) { static inline bool IsValidDirAttribute(const AtomicString& value) {
return DeprecatedEqualIgnoringCase(value, "ltr") || return EqualIgnoringASCIICase(value, "ltr") ||
DeprecatedEqualIgnoringCase(value, "rtl"); EqualIgnoringASCIICase(value, "rtl");
} }
// Keywords from MathML3 and CSS font-size are skipped. // Keywords from MathML3 and CSS font-size are skipped.
static inline bool IsDisallowedMathSizeAttribute(const AtomicString& value) { static inline bool IsDisallowedMathSizeAttribute(const AtomicString& value) {
return DeprecatedEqualIgnoringCase(value, "medium") || return EqualIgnoringASCIICase(value, "medium") ||
value.EndsWith("large", kTextCaseASCIIInsensitive) || value.EndsWith("large", kTextCaseASCIIInsensitive) ||
value.EndsWith("small", kTextCaseASCIIInsensitive) || value.EndsWith("small", kTextCaseASCIIInsensitive) ||
DeprecatedEqualIgnoringCase(value, "smaller") || EqualIgnoringASCIICase(value, "smaller") ||
DeprecatedEqualIgnoringCase(value, "larger"); EqualIgnoringASCIICase(value, "larger");
} }
bool MathMLElement::IsPresentationAttribute(const QualifiedName& name) const { bool MathMLElement::IsPresentationAttribute(const QualifiedName& name) const {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<title>mathsize and css keywords</title> <title>mathsize and css keywords</title>
</head> </head>
<body> <body>
<p>Test passes if you see ten "A" of equal size:</p> <p>Test passes if you see 14 "A" of equal size:</p>
<math> <math>
<mtext>A</mtext> <mtext>A</mtext>
<mtext>A</mtext> <mtext>A</mtext>
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
<mtext>A</mtext> <mtext>A</mtext>
<mtext>A</mtext> <mtext>A</mtext>
<mtext>A</mtext> <mtext>A</mtext>
<mtext>A</mtext>
<mtext>A</mtext>
<mtext>A</mtext>
<mtext>A</mtext>
</math> </math>
</body> </body>
</html> </html>
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<script src="/mathml/support/feature-detection.js"></script> <script src="/mathml/support/feature-detection.js"></script>
</head> </head>
<body> <body>
<p>Test passes if you see ten "A" of equal size:</p> <p>Test passes if you see 14 "A" of equal size:</p>
<math> <math>
<mtext>A</mtext> <mtext>A</mtext>
<mtext mathsize="xx-small">A</mtext> <mtext mathsize="xx-small">A</mtext>
...@@ -22,6 +22,10 @@ ...@@ -22,6 +22,10 @@
<mtext mathsize="xx-large">A</mtext> <mtext mathsize="xx-large">A</mtext>
<mtext mathsize="larger">A</mtext> <mtext mathsize="larger">A</mtext>
<mtext mathsize="smaller">A</mtext> <mtext mathsize="smaller">A</mtext>
<mtext mathsize="xx-ſmall">A</mtext>
<mtext mathsize="x-ſmall">A</mtext>
<mtext mathsize="ſmall">A</mtext>
<mtext mathsize="ſmaller">A</mtext>
</math> </math>
<script src="/mathml/support/feature-detection.js"></script> <script src="/mathml/support/feature-detection.js"></script>
<script>MathMLFeatureDetection.ensure_for_match_reftest("has_mathsize");</script> <script>MathMLFeatureDetection.ensure_for_match_reftest("has_mathsize");</script>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment