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. (http://www.t
orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 { | 228 { |
229 // FIXME: Title should be set. | 229 // FIXME: Title should be set. |
230 // FIXME: Media could have wrong syntax, in which case we should generate an
exception. | 230 // FIXME: Media could have wrong syntax, in which case we should generate an
exception. |
231 RefPtr<CSSStyleSheet> sheet = CSSStyleSheet::create(StyleSheetContents::crea
te()); | 231 RefPtr<CSSStyleSheet> sheet = CSSStyleSheet::create(StyleSheetContents::crea
te()); |
232 sheet->setMediaQueries(MediaQuerySet::create(media)); | 232 sheet->setMediaQueries(MediaQuerySet::create(media)); |
233 return sheet; | 233 return sheet; |
234 } | 234 } |
235 | 235 |
236 bool DOMImplementation::isXMLMIMEType(const String& mimeType) | 236 bool DOMImplementation::isXMLMIMEType(const String& mimeType) |
237 { | 237 { |
238 if (mimeType == "text/xml" || mimeType == "application/xml" || mimeType == "
text/xsl") | 238 if (equalIgnoringCase(mimeType, "text/xml") |
| 239 || equalIgnoringCase(mimeType, "application/xml") |
| 240 || equalIgnoringCase(mimeType, "text/xsl")) |
239 return true; | 241 return true; |
240 | 242 |
241 // Per RFCs 3023 and 2045 a mime type is of the form: | 243 // Per RFCs 3023 and 2045, an XML MIME type is of the form: |
242 // ^[0-9a-zA-Z_\\-+~!$\\^{}|.%'`#&*]+/[0-9a-zA-Z_\\-+~!$\\^{}|.%'`#&*]+\+xml
$ | 244 // ^[0-9a-zA-Z_\\-+~!$\\^{}|.%'`#&*]+/[0-9a-zA-Z_\\-+~!$\\^{}|.%'`#&*]+\+xml
$ |
243 | 245 |
244 int length = mimeType.length(); | 246 int length = mimeType.length(); |
245 if (length < 7) | 247 if (length < 7) |
246 return false; | 248 return false; |
247 | 249 |
248 if (mimeType[0] == '/' || | 250 if (mimeType[0] == '/' || mimeType[length - 5] == '/' || !mimeType.endsWith(
"+xml", false)) |
249 mimeType[length - 5] == '/' || | |
250 mimeType[length - 4] != '+' || | |
251 mimeType[length - 3] != 'x' || | |
252 mimeType[length - 2] != 'm' || | |
253 mimeType[length - 1] != 'l') | |
254 return false; | 251 return false; |
255 | 252 |
256 bool hasSlash = false; | 253 bool hasSlash = false; |
257 for (int i = 0; i < length - 4; ++i) { | 254 for (int i = 0; i < length - 4; ++i) { |
258 UChar ch = mimeType[i]; | 255 UChar ch = mimeType[i]; |
259 if (ch >= '0' && ch <= '9') | 256 if (ch >= '0' && ch <= '9') |
260 continue; | 257 continue; |
261 if (ch >= 'a' && ch <= 'z') | 258 if (ch >= 'a' && ch <= 'z') |
262 continue; | 259 continue; |
263 if (ch >= 'A' && ch <= 'Z') | 260 if (ch >= 'A' && ch <= 'Z') |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 return TextDocument::create(init); | 377 return TextDocument::create(init); |
381 if (type == "image/svg+xml") | 378 if (type == "image/svg+xml") |
382 return SVGDocument::create(init); | 379 return SVGDocument::create(init); |
383 if (isXMLMIMEType(type)) | 380 if (isXMLMIMEType(type)) |
384 return Document::create(init); | 381 return Document::create(init); |
385 | 382 |
386 return HTMLDocument::create(init); | 383 return HTMLDocument::create(init); |
387 } | 384 } |
388 | 385 |
389 } | 386 } |
OLD | NEW |