| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 6 * Copyright (C) 2006 Samuel Weinig (sam@webkit.org) | 6 * Copyright (C) 2006 Samuel Weinig (sam@webkit.org) |
| 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 8 * (http://www.torchmobile.com/) | 8 * (http://www.torchmobile.com/) |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 return true; | 118 return true; |
| 119 | 119 |
| 120 // Per RFCs 3023 and 2045, an XML MIME type is of the form: | 120 // Per RFCs 3023 and 2045, an XML MIME type is of the form: |
| 121 // ^[0-9a-zA-Z_\\-+~!$\\^{}|.%'`#&*]+/[0-9a-zA-Z_\\-+~!$\\^{}|.%'`#&*]+\+xml$ | 121 // ^[0-9a-zA-Z_\\-+~!$\\^{}|.%'`#&*]+/[0-9a-zA-Z_\\-+~!$\\^{}|.%'`#&*]+\+xml$ |
| 122 | 122 |
| 123 int length = mimeType.length(); | 123 int length = mimeType.length(); |
| 124 if (length < 7) | 124 if (length < 7) |
| 125 return false; | 125 return false; |
| 126 | 126 |
| 127 if (mimeType[0] == '/' || mimeType[length - 5] == '/' || | 127 if (mimeType[0] == '/' || mimeType[length - 5] == '/' || |
| 128 !mimeType.endsWith("+xml", TextCaseInsensitive)) | 128 !mimeType.endsWith("+xml", TextCaseASCIIInsensitive)) |
| 129 return false; | 129 return false; |
| 130 | 130 |
| 131 bool hasSlash = false; | 131 bool hasSlash = false; |
| 132 for (int i = 0; i < length - 4; ++i) { | 132 for (int i = 0; i < length - 4; ++i) { |
| 133 UChar ch = mimeType[i]; | 133 UChar ch = mimeType[i]; |
| 134 if (ch >= '0' && ch <= '9') | 134 if (ch >= '0' && ch <= '9') |
| 135 continue; | 135 continue; |
| 136 if (ch >= 'a' && ch <= 'z') | 136 if (ch >= 'a' && ch <= 'z') |
| 137 continue; | 137 continue; |
| 138 if (ch >= 'A' && ch <= 'Z') | 138 if (ch >= 'A' && ch <= 'Z') |
| (...skipping 24 matching lines...) Expand all Loading... |
| 163 continue; | 163 continue; |
| 164 default: | 164 default: |
| 165 return false; | 165 return false; |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 | 168 |
| 169 return true; | 169 return true; |
| 170 } | 170 } |
| 171 | 171 |
| 172 bool DOMImplementation::isJSONMIMEType(const String& mimeType) { | 172 bool DOMImplementation::isJSONMIMEType(const String& mimeType) { |
| 173 if (mimeType.startsWith("application/json", TextCaseInsensitive)) | 173 if (mimeType.startsWith("application/json", TextCaseASCIIInsensitive)) |
| 174 return true; | 174 return true; |
| 175 if (mimeType.startsWith("application/", TextCaseInsensitive)) { | 175 if (mimeType.startsWith("application/", TextCaseASCIIInsensitive)) { |
| 176 size_t subtype = mimeType.find("+json", 12, TextCaseInsensitive); | 176 size_t subtype = mimeType.find("+json", 12, TextCaseASCIIInsensitive); |
| 177 if (subtype != kNotFound) { | 177 if (subtype != kNotFound) { |
| 178 // Just check that a parameter wasn't matched. | 178 // Just check that a parameter wasn't matched. |
| 179 size_t parameterMarker = mimeType.find(";"); | 179 size_t parameterMarker = mimeType.find(";"); |
| 180 if (parameterMarker == kNotFound) { | 180 if (parameterMarker == kNotFound) { |
| 181 unsigned endSubtype = static_cast<unsigned>(subtype) + 5; | 181 unsigned endSubtype = static_cast<unsigned>(subtype) + 5; |
| 182 return endSubtype == mimeType.length() || | 182 return endSubtype == mimeType.length() || |
| 183 isASCIISpace(mimeType[endSubtype]); | 183 isASCIISpace(mimeType[endSubtype]); |
| 184 } | 184 } |
| 185 return parameterMarker > subtype; | 185 return parameterMarker > subtype; |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 return false; | 188 return false; |
| 189 } | 189 } |
| 190 | 190 |
| 191 static bool isTextPlainType(const String& mimeType) { | 191 static bool isTextPlainType(const String& mimeType) { |
| 192 return mimeType.startsWith("text/", TextCaseInsensitive) && | 192 return mimeType.startsWith("text/", TextCaseASCIIInsensitive) && |
| 193 !(equalIgnoringCase(mimeType, "text/html") || | 193 !(equalIgnoringCase(mimeType, "text/html") || |
| 194 equalIgnoringCase(mimeType, "text/xml") || | 194 equalIgnoringCase(mimeType, "text/xml") || |
| 195 equalIgnoringCase(mimeType, "text/xsl")); | 195 equalIgnoringCase(mimeType, "text/xsl")); |
| 196 } | 196 } |
| 197 | 197 |
| 198 bool DOMImplementation::isTextMIMEType(const String& mimeType) { | 198 bool DOMImplementation::isTextMIMEType(const String& mimeType) { |
| 199 return MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType) || | 199 return MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType) || |
| 200 isJSONMIMEType(mimeType) || isTextPlainType(mimeType); | 200 isJSONMIMEType(mimeType) || isTextPlainType(mimeType); |
| 201 } | 201 } |
| 202 | 202 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 return XMLDocument::create(init); | 276 return XMLDocument::create(init); |
| 277 | 277 |
| 278 return HTMLDocument::create(init); | 278 return HTMLDocument::create(init); |
| 279 } | 279 } |
| 280 | 280 |
| 281 DEFINE_TRACE(DOMImplementation) { | 281 DEFINE_TRACE(DOMImplementation) { |
| 282 visitor->trace(m_document); | 282 visitor->trace(m_document); |
| 283 } | 283 } |
| 284 | 284 |
| 285 } // namespace blink | 285 } // namespace blink |
| OLD | NEW |