| Index: Source/core/dom/DOMImplementation.cpp
|
| diff --git a/Source/core/dom/DOMImplementation.cpp b/Source/core/dom/DOMImplementation.cpp
|
| index 83885b3bf10f9d2f46ba4d3d4526b052b8891ba8..14f2aba014b86eb8a9840ac55cb1a9afe5dcb209 100644
|
| --- a/Source/core/dom/DOMImplementation.cpp
|
| +++ b/Source/core/dom/DOMImplementation.cpp
|
| @@ -294,17 +294,47 @@ bool DOMImplementation::isXMLMIMEType(const String& mimeType)
|
| return true;
|
| }
|
|
|
| +static bool isJSONType(const String& mimeType)
|
| +{
|
| + if (mimeType.startsWith("application/json", false))
|
| + return true;
|
| + if (mimeType.startsWith("application/", false)) {
|
| + size_t subtype = mimeType.find("+json", 12, false);
|
| + if (subtype != kNotFound) {
|
| + // Just check that a parameter wasn't matched.
|
| + size_t parameterMarker = mimeType.find(";");
|
| + return (parameterMarker == kNotFound || parameterMarker > subtype);
|
| + }
|
| + }
|
| + return false;
|
| +}
|
| +
|
| +static bool isTextPlainType(const String& mimeType)
|
| +{
|
| + return (mimeType.startsWith("text/", false)
|
| + && !(equalIgnoringCase(mimeType, "text/html")
|
| + || equalIgnoringCase(mimeType, "text/xml")
|
| + || equalIgnoringCase(mimeType, "text/xsl")));
|
| +}
|
| +
|
| bool DOMImplementation::isTextMIMEType(const String& mimeType)
|
| {
|
| - if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType)
|
| - || mimeType == "application/json" // Render JSON as text/plain.
|
| - || (mimeType.startsWith("text/") && mimeType != "text/html"
|
| - && mimeType != "text/xml" && mimeType != "text/xsl"))
|
| + if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType) || isJSONType(mimeType) || isTextPlainType(mimeType))
|
| return true;
|
|
|
| return false;
|
| }
|
|
|
| +const char* DOMImplementation::getTextDefaultEncodingName(const String& mimeType)
|
| +{
|
| + ASSERT(isTextMIMEType(mimeType));
|
| + if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType) || isJSONType(mimeType))
|
| + return "UTF-8";
|
| +
|
| + // The HTTP/1.1 default.
|
| + return "ISO-8859-1";
|
| +}
|
| +
|
| PassRefPtr<HTMLDocument> DOMImplementation::createHTMLDocument(const String& title)
|
| {
|
| DocumentInit init = DocumentInit::fromContext(m_document.contextDocument())
|
|
|