| 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. (http://www.torchmo
bile.com/) | 8 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.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 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 xmlRegisterOutputCallbacks(matchFunc, openFunc, writeFunc, closeFunc); | 727 xmlRegisterOutputCallbacks(matchFunc, openFunc, writeFunc, closeFunc); |
| 728 libxmlLoaderThread = currentThread(); | 728 libxmlLoaderThread = currentThread(); |
| 729 didInit = true; | 729 didInit = true; |
| 730 } | 730 } |
| 731 | 731 |
| 732 | 732 |
| 733 PassRefPtr<XMLParserContext> XMLParserContext::createStringParser(xmlSAXHandlerP
tr handlers, void* userData) | 733 PassRefPtr<XMLParserContext> XMLParserContext::createStringParser(xmlSAXHandlerP
tr handlers, void* userData) |
| 734 { | 734 { |
| 735 initializeLibXMLIfNecessary(); | 735 initializeLibXMLIfNecessary(); |
| 736 xmlParserCtxtPtr parser = xmlCreatePushParserCtxt(handlers, 0, 0, 0, 0); | 736 xmlParserCtxtPtr parser = xmlCreatePushParserCtxt(handlers, 0, 0, 0, 0); |
| 737 xmlCtxtUseOptions(parser, XML_PARSE_HUGE); |
| 737 parser->_private = userData; | 738 parser->_private = userData; |
| 738 parser->replaceEntities = true; | 739 parser->replaceEntities = true; |
| 739 return adoptRef(new XMLParserContext(parser)); | 740 return adoptRef(new XMLParserContext(parser)); |
| 740 } | 741 } |
| 741 | 742 |
| 742 // Chunk should be encoded in UTF-8 | 743 // Chunk should be encoded in UTF-8 |
| 743 PassRefPtr<XMLParserContext> XMLParserContext::createMemoryParser(xmlSAXHandlerP
tr handlers, void* userData, const CString& chunk) | 744 PassRefPtr<XMLParserContext> XMLParserContext::createMemoryParser(xmlSAXHandlerP
tr handlers, void* userData, const CString& chunk) |
| 744 { | 745 { |
| 745 initializeLibXMLIfNecessary(); | 746 initializeLibXMLIfNecessary(); |
| 746 | 747 |
| 747 // appendFragmentSource() checks that the length doesn't overflow an int. | 748 // appendFragmentSource() checks that the length doesn't overflow an int. |
| 748 xmlParserCtxtPtr parser = xmlCreateMemoryParserCtxt(chunk.data(), chunk.leng
th()); | 749 xmlParserCtxtPtr parser = xmlCreateMemoryParserCtxt(chunk.data(), chunk.leng
th()); |
| 749 | 750 |
| 750 if (!parser) | 751 if (!parser) |
| 751 return nullptr; | 752 return nullptr; |
| 752 | 753 |
| 753 // Copy the sax handler | 754 // Copy the sax handler |
| 754 memcpy(parser->sax, handlers, sizeof(xmlSAXHandler)); | 755 memcpy(parser->sax, handlers, sizeof(xmlSAXHandler)); |
| 755 | 756 |
| 756 // Set parser options. | 757 // Set parser options. |
| 757 // XML_PARSE_NODICT: default dictionary option. | 758 // XML_PARSE_NODICT: default dictionary option. |
| 758 // XML_PARSE_NOENT: force entities substitutions. | 759 // XML_PARSE_NOENT: force entities substitutions. |
| 759 xmlCtxtUseOptions(parser, XML_PARSE_NODICT | XML_PARSE_NOENT); | 760 // XML_PARSE_HUGE: don't impose arbitrary limits on document size. |
| 761 xmlCtxtUseOptions(parser, XML_PARSE_NODICT | XML_PARSE_NOENT | XML_PARSE_HUG
E); |
| 760 | 762 |
| 761 // Internal initialization | 763 // Internal initialization |
| 762 parser->sax2 = 1; | 764 parser->sax2 = 1; |
| 763 parser->instate = XML_PARSER_CONTENT; // We are parsing a CONTENT | 765 parser->instate = XML_PARSER_CONTENT; // We are parsing a CONTENT |
| 764 parser->depth = 0; | 766 parser->depth = 0; |
| 765 parser->str_xml = xmlDictLookup(parser->dict, BAD_CAST "xml", 3); | 767 parser->str_xml = xmlDictLookup(parser->dict, BAD_CAST "xml", 3); |
| 766 parser->str_xmlns = xmlDictLookup(parser->dict, BAD_CAST "xmlns", 5); | 768 parser->str_xmlns = xmlDictLookup(parser->dict, BAD_CAST "xmlns", 5); |
| 767 parser->str_xml_ns = xmlDictLookup(parser->dict, XML_XML_NAMESPACE, 36); | 769 parser->str_xml_ns = xmlDictLookup(parser->dict, XML_XML_NAMESPACE, 36); |
| 768 parser->_private = userData; | 770 parser->_private = userData; |
| 769 | 771 |
| (...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1682 sax.initialized = XML_SAX2_MAGIC; | 1684 sax.initialized = XML_SAX2_MAGIC; |
| 1683 RefPtr<XMLParserContext> parser = XMLParserContext::createStringParser(&sax,
&state); | 1685 RefPtr<XMLParserContext> parser = XMLParserContext::createStringParser(&sax,
&state); |
| 1684 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; | 1686 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; |
| 1685 parseChunk(parser->context(), parseString); | 1687 parseChunk(parser->context(), parseString); |
| 1686 finishParsing(parser->context()); | 1688 finishParsing(parser->context()); |
| 1687 attrsOK = state.gotAttributes; | 1689 attrsOK = state.gotAttributes; |
| 1688 return state.attributes; | 1690 return state.attributes; |
| 1689 } | 1691 } |
| 1690 | 1692 |
| 1691 } // namespace blink | 1693 } // namespace blink |
| OLD | NEW |