Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xml.sax.xmlreader.AttributesImpl allows empty string as attribute names #57092

Open
MichaelSulyaev mannequin opened this issue Sep 2, 2011 · 5 comments
Open

xml.sax.xmlreader.AttributesImpl allows empty string as attribute names #57092

MichaelSulyaev mannequin opened this issue Sep 2, 2011 · 5 comments
Labels
3.13 new features, bugs and security fixes stdlib Python modules in the Lib dir topic-XML type-feature A feature request or enhancement

Comments

@MichaelSulyaev
Copy link
Mannequin

MichaelSulyaev mannequin commented Sep 2, 2011

BPO 12883
Nosy @iritkatriel
Files
  • w.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2011-09-02.10:04:02.189>
    labels = ['expert-XML', 'type-bug', '3.11']
    title = 'xml.sax.xmlreader.AttributesImpl allows empty string as attribute names'
    updated_at = <Date 2021-04-30.10:10:21.477>
    user = 'https://bugs.python.org/MichaelSulyaev'

    bugs.python.org fields:

    activity = <Date 2021-04-30.10:10:21.477>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['XML']
    creation = <Date 2011-09-02.10:04:02.189>
    creator = 'Michael.Sulyaev'
    dependencies = []
    files = ['28915']
    hgrepos = []
    issue_num = 12883
    keywords = ['patch']
    message_count = 4.0
    messages = ['143391', '180964', '181008', '392406']
    nosy_count = 4.0
    nosy_names = ['Ramchandra Apte', 'Michael.Sulyaev', 'Chenguang.Wang', 'iritkatriel']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue12883'
    versions = ['Python 3.11']

    @MichaelSulyaev
    Copy link
    Mannequin Author

    MichaelSulyaev mannequin commented Sep 2, 2011

    I can get not-well-formed XML output (attribute name must not be empty string):

    <?xml version="1.0" encoding="iso-8859-1"?>
    <root ="v_for_empty_name" k1="v1"></root>

    AttributeImpl must ignore dict entries that may not be cast to valid XML attributes.

    Code:

    #!/usr/bin/python

    from xml.sax.xmlreader import AttributesImpl as Attrs
    from xml.sax.saxutils import XMLGenerator as Gen
    
    g = Gen()
    a = Attrs(dict([('k1','v1'),('','v_for_empty_name')]))
    g.startDocument()
    g.startElement('root',a)
    g.endElement('root')
    g.endDocument()
    print

    @MichaelSulyaev MichaelSulyaev mannequin added topic-XML type-bug An unexpected behavior, bug, or error labels Sep 2, 2011
    @RamchandraApte
    Copy link
    Mannequin

    RamchandraApte mannequin commented Jan 30, 2013

    bump...

    @ChenguangWang
    Copy link
    Mannequin

    ChenguangWang mannequin commented Jan 31, 2013

    I found this problem is still not fixed in the lastest hg version. Seriously?

    This patch is for the latest v3.4.0a0.

    @iritkatriel
    Copy link
    Member

    I don't think the proposed patch is an acceptable solution. It silently skips invalid attributes.

    It would be ok to either raise an exception or to leave it as it is (junk-in-junk-out). I'm not sure which is better.

    @iritkatriel iritkatriel added the 3.11 only security fixes label Apr 30, 2021
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @iritkatriel iritkatriel added type-feature A feature request or enhancement stdlib Python modules in the Lib dir 3.13 new features, bugs and security fixes and removed type-bug An unexpected behavior, bug, or error 3.11 only security fixes labels Nov 22, 2023
    @iritkatriel
    Copy link
    Member

    The documentation doesn't say anything about input validation, so this is a feature request rather than a bug.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.13 new features, bugs and security fixes stdlib Python modules in the Lib dir topic-XML type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant