Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(419)

Unified Diff: Source/core/dom/DOMImplementation.cpp

Issue 122743002: MIME type predicates and case-insensitive matching. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Simplify check for empty +xml subtype Created 6 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/DOMImplementation.h ('k') | Source/core/dom/DOMImplementationTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/DOMImplementation.cpp
diff --git a/Source/core/dom/DOMImplementation.cpp b/Source/core/dom/DOMImplementation.cpp
index ac17ccb749655871ed4312d8d64dc5efab282290..2a6c9d42f6f91a007a98c862888c9c1174aac782 100644
--- a/Source/core/dom/DOMImplementation.cpp
+++ b/Source/core/dom/DOMImplementation.cpp
@@ -235,22 +235,19 @@ PassRefPtr<CSSStyleSheet> DOMImplementation::createCSSStyleSheet(const String&,
bool DOMImplementation::isXMLMIMEType(const String& mimeType)
{
- if (mimeType == "text/xml" || mimeType == "application/xml" || mimeType == "text/xsl")
+ if (equalIgnoringCase(mimeType, "text/xml")
+ || equalIgnoringCase(mimeType, "application/xml")
+ || equalIgnoringCase(mimeType, "text/xsl"))
return true;
- // Per RFCs 3023 and 2045 a mime type is of the form:
+ // Per RFCs 3023 and 2045, an XML MIME type is of the form:
// ^[0-9a-zA-Z_\\-+~!$\\^{}|.%'`#&*]+/[0-9a-zA-Z_\\-+~!$\\^{}|.%'`#&*]+\+xml$
int length = mimeType.length();
if (length < 7)
return false;
- if (mimeType[0] == '/' ||
- mimeType[length - 5] == '/' ||
- mimeType[length - 4] != '+' ||
- mimeType[length - 3] != 'x' ||
- mimeType[length - 2] != 'm' ||
- mimeType[length - 1] != 'l')
+ if (mimeType[0] == '/' || mimeType[length - 5] == '/' || !mimeType.endsWith("+xml", false))
return false;
bool hasSlash = false;
« no previous file with comments | « Source/core/dom/DOMImplementation.h ('k') | Source/core/dom/DOMImplementationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698