Skip to content

XML fails validation if it contains an attribute called "length" #129

@brainsiq

Description

@brainsiq

If you try to validate an XML document that has a "length" attribute anywhere it fails with an error "attribute length is repeated". I've tracked this down to the use of an array here in the validator. The code that checks for repeated attributes checks if length is a property of the array. It appears that attrNames can just be initialised as an object instead of an array to resolve this issue.

Checklist

  • Are you running the latest version?
  • Have you included sample input, output, error, and expected output?
  • Have you checked if you are using correct configuration?
  • Did you try online tool?

Input

<test length="1"></test>

Code

require('fast-xml-parser').validate('<test length="1"></test>');

Output

{ err: { code: 'InvalidAttr', msg: 'attribute length is repeated.' } }

expected data

true

Would you like to work on this issue?

  • Yes
  • No

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions