canonicalize crashes on namespace with no prefix

Bug #1869455 reported by Paul Prescod
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
lxml
Fix Released
Medium
scoder

Bug Description

https://repl.it/repls/TrustworthyStimulatingRedundancy

Python : sys.version_info(major=3, minor=8, micro=1, releaselevel='final', serial=0)
lxml.etree : (4, 5, 0, 0)
libxml used : (2, 9, 10)
libxml compiled : (2, 9, 10)
libxslt used : (1, 1, 34)
libxslt compiled : (1, 1, 34)

Script:

xml="""
<X xmlns="http://soap.sforce.com/2006/04/metadata">
    <Y targets="lightning__AppPage,lightning__HomePage"></Y>
</X>"""
print(etree.canonicalize(xml))

Exception:

  File "src/lxml/serializer.pxi", line 1079, in lxml.etree.C14NWriterTarget._qname
ValueError: Namespace "" is not declared in scope

Revision history for this message
scoder (scoder) wrote :

Interesting. Thanks for reporting this (and sorry for missing it earlier this year).
This also needs fixing in CPython then, since both ElementTree and lxml are using (mostly) the same implementation here.

Changed in lxml:
assignee: nobody → scoder (scoder)
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
scoder (scoder) wrote :
Changed in lxml:
milestone: none → 4.6.0
status: Confirmed → Fix Committed
Revision history for this message
scoder (scoder) wrote :

Proposed fix for CPython is here:
https://github.com/python/cpython/pull/22474

scoder (scoder)
Changed in lxml:
status: Fix Committed → Fix Released
Revision history for this message
Paul Prescod (prescod) wrote : Re: [Bug 1869455] Re: canonicalize crashes on namespace with no prefix

Thank you!

On Sun, Oct 18, 2020 at 6:50 AM scoder <email address hidden> wrote:

> ** Changed in: lxml
> Status: Fix Committed => Fix Released
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1869455
>
> Title:
> canonicalize crashes on namespace with no prefix
>
> Status in lxml:
> Fix Released
>
> Bug description:
> https://repl.it/repls/TrustworthyStimulatingRedundancy
>
> Python : sys.version_info(major=3, minor=8, micro=1,
> releaselevel='final', serial=0)
> lxml.etree : (4, 5, 0, 0)
> libxml used : (2, 9, 10)
> libxml compiled : (2, 9, 10)
> libxslt used : (1, 1, 34)
> libxslt compiled : (1, 1, 34)
>
> Script:
>
> xml="""
> <X xmlns="http://soap.sforce.com/2006/04/metadata">
> <Y targets="lightning__AppPage,lightning__HomePage"></Y>
> </X>"""
> print(etree.canonicalize(xml))
>
> Exception:
>
> File "src/lxml/serializer.pxi", line 1079, in
> lxml.etree.C14NWriterTarget._qname
> ValueError: Namespace "" is not declared in scope
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/lxml/+bug/1869455/+subscriptions
>

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers