javascript - fast-xml-parser 认为结束标签在没有结束括号的情况下也是有效的

标签 javascript xml parsing

我正在尝试使用 fast-xml-parser 在 React 应用程序中动态验证一些输入 xml。我只是使用开箱即用的默认选项,当我尝试 <test></test 时它返回为有效。

这里我输出我正在运行的文本 parser.validate()以及它到控制台的返回值:

enter image description here

我也在他们的在线工具中尝试过: In what world is this valid?

不要无礼,但我是否在选项中错过了“做正确且明显的事情”开关或其他内容?我之所以问这个问题,是因为我想发布一个问题,并且必须首先向 Stackoverflow 询问。

最佳答案

这显然是一个错误...

Not to be rude, but am I missing a "do the right and obvious thing" switch in the options or something? I'm asking because I want to post an issue, and asking Stackoverflow first is a requirement.

  1. 你没有无礼。 粗鲁是期望SO对错误报告进行分类(令人尴尬是要求通过这样的政策更多地关注错误)。

  2. 另请注意 fast-xml-parser 的作者滥用术语有效
    请参阅Well-formed vs Valid XML .

...但这比孤立的错误更糟糕:

来自 fast-xml-parser limitations section :

Limitations

Currently FXP fails to parse XML with attributes has ">" in the value. This problem is left open as change in regex for its fix is degrading the performance. And the parser become very slow in case of long attrbute [sic] names.

  • 任何基于正则表达式的 XML“解析器”都是一个玩具,不应该用于专业用途。
  • 底线:这比孤立的错误更严重。这只是 fast-xml-parser 中严重设计缺陷的冰山一 Angular 。 建议:避免。

    关于javascript - fast-xml-parser 认为结束标签在没有结束括号的情况下也是有效的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57980770/

    相关文章:

    javascript - 使用 JSON API 根据用户点击事件检索数据

    javascript - 数组的数组格式问题

    javascript - RESTful Web 应用程序中的客户端服务器架构

    javascript - Controller 中的 Angularjs href

    java - 一个不错的 Java XML DOM 实用程序

    android - 如何仅从 json 解析直接 json 对象

    java - 解码原始无模式 XML

    mysql - 有没有不用安装就可以使用的数据库系统

    JavaScript 解析树

    parsing - 解析二叉树(读取 a,显示 a)