OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2000 Peter Kelly (pmk@post.com) | 2 * Copyright (C) 2000 Peter Kelly (pmk@post.com) |
3 * Copyright (C) 2005, 2006, 2008, 2014 Apple Inc. All rights reserved. | 3 * Copyright (C) 2005, 2006, 2008, 2014 Apple Inc. All rights reserved. |
4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
5 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) | 5 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) |
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
7 * Copyright (C) 2008 Holger Hans Peter Freyther | 7 * Copyright (C) 2008 Holger Hans Peter Freyther |
8 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. |
9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
10 * | 10 * |
11 * This library is free software; you can redistribute it and/or | 11 * This library is free software; you can redistribute it and/or |
12 * modify it under the terms of the GNU Library General Public | 12 * modify it under the terms of the GNU Library General Public |
13 * License as published by the Free Software Foundation; either | 13 * License as published by the Free Software Foundation; either |
14 * version 2 of the License, or (at your option) any later version. | 14 * version 2 of the License, or (at your option) any later version. |
15 * | 15 * |
16 * This library is distributed in the hope that it will be useful, | 16 * This library is distributed in the hope that it will be useful, |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 * Library General Public License for more details. | 19 * Library General Public License for more details. |
20 * | 20 * |
21 * You should have received a copy of the GNU Library General Public License | 21 * You should have received a copy of the GNU Library General Public License |
22 * along with this library; see the file COPYING.LIB. If not, write to | 22 * along with this library; see the file COPYING.LIB. If not, write to |
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 * Boston, MA 02110-1301, USA. | 24 * Boston, MA 02110-1301, USA. |
25 */ | 25 */ |
26 | 26 |
27 #include "core/xml/parser/XMLDocumentParser.h" | 27 #include "core/xml/parser/XMLDocumentParser.h" |
28 | 28 |
29 #include <libxml/catalog.h> | |
30 #include <libxml/parser.h> | 29 #include <libxml/parser.h> |
31 #include <libxml/parserInternals.h> | 30 #include <libxml/parserInternals.h> |
32 #include <libxslt/xslt.h> | 31 #include <libxslt/xslt.h> |
33 #include <memory> | 32 #include <memory> |
34 #include "bindings/core/v8/ExceptionState.h" | 33 #include "bindings/core/v8/ExceptionState.h" |
35 #include "bindings/core/v8/ScriptController.h" | 34 #include "bindings/core/v8/ScriptController.h" |
36 #include "bindings/core/v8/ScriptSourceCode.h" | 35 #include "bindings/core/v8/ScriptSourceCode.h" |
37 #include "core/HTMLNames.h" | 36 #include "core/HTMLNames.h" |
38 #include "core/XMLNSNames.h" | 37 #include "core/XMLNSNames.h" |
39 #include "core/dom/CDATASection.h" | 38 #include "core/dom/CDATASection.h" |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 } | 564 } |
566 | 565 |
567 static void finishParsing(xmlParserCtxtPtr ctxt) { | 566 static void finishParsing(xmlParserCtxtPtr ctxt) { |
568 xmlParseChunk(ctxt, 0, 0, 1); | 567 xmlParseChunk(ctxt, 0, 0, 1); |
569 } | 568 } |
570 | 569 |
571 #define xmlParseChunk \ | 570 #define xmlParseChunk \ |
572 #error "Use parseChunk instead to select the correct encoding." | 571 #error "Use parseChunk instead to select the correct encoding." |
573 | 572 |
574 static bool isLibxmlDefaultCatalogFile(const String& urlString) { | 573 static bool isLibxmlDefaultCatalogFile(const String& urlString) { |
575 // On non-Windows platforms libxml asks for this URL, the | 574 // On non-Windows platforms libxml with catalogs enabled asks for |
576 // "XML_XML_DEFAULT_CATALOG", on initialization. | 575 // this URL, the "XML_XML_DEFAULT_CATALOG", on initialization. |
577 if (urlString == "file:///etc/xml/catalog") | 576 if (urlString == "file:///etc/xml/catalog") |
578 return true; | 577 return true; |
579 | 578 |
580 // On Windows, libxml computes a URL relative to where its DLL resides. | 579 // On Windows, libxml with catalogs enabled computes a URL relative |
| 580 // to where its DLL resides. |
581 if (urlString.startsWith("file:///", TextCaseASCIIInsensitive) && | 581 if (urlString.startsWith("file:///", TextCaseASCIIInsensitive) && |
582 urlString.endsWith("/etc/catalog", TextCaseASCIIInsensitive)) | 582 urlString.endsWith("/etc/catalog", TextCaseASCIIInsensitive)) |
583 return true; | 583 return true; |
584 return false; | 584 return false; |
585 } | 585 } |
586 | 586 |
587 static bool shouldAllowExternalLoad(const KURL& url) { | 587 static bool shouldAllowExternalLoad(const KURL& url) { |
588 String urlString = url.getString(); | 588 String urlString = url.getString(); |
589 | 589 |
590 // This isn't really necessary now that initializeLibXMLIfNecessary | 590 // libxml should not be configured with catalogs enabled, so it |
591 // disables catalog support in libxml, but keeping it for defense in depth. | 591 // should not be asking to load default catalogs. |
592 if (isLibxmlDefaultCatalogFile(url)) | 592 CHECK(!isLibxmlDefaultCatalogFile(url)); |
593 return false; | |
594 | 593 |
595 // The most common DTD. There isn't much point in hammering www.w3c.org by | 594 // The most common DTD. There isn't much point in hammering www.w3c.org by |
596 // requesting this URL for every XHTML document. | 595 // requesting this URL for every XHTML document. |
597 if (urlString.startsWith("http://www.w3.org/TR/xhtml", | 596 if (urlString.startsWith("http://www.w3.org/TR/xhtml", |
598 TextCaseASCIIInsensitive)) | 597 TextCaseASCIIInsensitive)) |
599 return false; | 598 return false; |
600 | 599 |
601 // Similarly, there isn't much point in requesting the SVG DTD. | 600 // Similarly, there isn't much point in requesting the SVG DTD. |
602 if (urlString.startsWith("http://www.w3.org/Graphics/SVG", | 601 if (urlString.startsWith("http://www.w3.org/Graphics/SVG", |
603 TextCaseASCIIInsensitive)) | 602 TextCaseASCIIInsensitive)) |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 | 689 |
691 static void errorFunc(void*, const char*, ...) { | 690 static void errorFunc(void*, const char*, ...) { |
692 // FIXME: It would be nice to display error messages somewhere. | 691 // FIXME: It would be nice to display error messages somewhere. |
693 } | 692 } |
694 | 693 |
695 static void initializeLibXMLIfNecessary() { | 694 static void initializeLibXMLIfNecessary() { |
696 static bool didInit = false; | 695 static bool didInit = false; |
697 if (didInit) | 696 if (didInit) |
698 return; | 697 return; |
699 | 698 |
700 // We don't want libxml to try and load catalogs. | |
701 // FIXME: It's not nice to set global settings in libxml, embedders of Blink | |
702 // could be trying to use libxml themselves. | |
703 xmlCatalogSetDefaults(XML_CATA_ALLOW_NONE); | |
704 xmlInitParser(); | 699 xmlInitParser(); |
705 xmlRegisterInputCallbacks(matchFunc, openFunc, readFunc, closeFunc); | 700 xmlRegisterInputCallbacks(matchFunc, openFunc, readFunc, closeFunc); |
706 xmlRegisterOutputCallbacks(matchFunc, openFunc, writeFunc, closeFunc); | 701 xmlRegisterOutputCallbacks(matchFunc, openFunc, writeFunc, closeFunc); |
707 libxmlLoaderThread = currentThread(); | 702 libxmlLoaderThread = currentThread(); |
708 didInit = true; | 703 didInit = true; |
709 } | 704 } |
710 | 705 |
711 PassRefPtr<XMLParserContext> XMLParserContext::createStringParser( | 706 PassRefPtr<XMLParserContext> XMLParserContext::createStringParser( |
712 xmlSAXHandlerPtr handlers, | 707 xmlSAXHandlerPtr handlers, |
713 void* userData) { | 708 void* userData) { |
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1716 RefPtr<XMLParserContext> parser = | 1711 RefPtr<XMLParserContext> parser = |
1717 XMLParserContext::createStringParser(&sax, &state); | 1712 XMLParserContext::createStringParser(&sax, &state); |
1718 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; | 1713 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; |
1719 parseChunk(parser->context(), parseString); | 1714 parseChunk(parser->context(), parseString); |
1720 finishParsing(parser->context()); | 1715 finishParsing(parser->context()); |
1721 attrsOK = state.gotAttributes; | 1716 attrsOK = state.gotAttributes; |
1722 return state.attributes; | 1717 return state.attributes; |
1723 } | 1718 } |
1724 | 1719 |
1725 } // namespace blink | 1720 } // namespace blink |
OLD | NEW |