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

Detecting unescaped xml entities #30

Open
demimismo opened this issue Nov 29, 2014 · 0 comments
Open

Detecting unescaped xml entities #30

demimismo opened this issue Nov 29, 2014 · 0 comments

Comments

@demimismo
Copy link

equivalent-xml ignores unescaped XML entities. Try with this spec:

  it "should detect xml entities" do
    doc1 = "<doc xmlns='foo:bar'><first order='1'>Sam & Max</first><second>things</second></doc>"
    doc2 = "<doc xmlns='foo:bar'><first order='1'>Sam Max</first><second>things</second></doc>"
    expect(doc1).not_to be_equivalent_to(doc2)
  end

That fails because Nokogiri is not configured with STRICT or NOENT options (see here)

I'm not sure what would be the most appropriate behaviour. Using STRICT would break other specs, like the one where you're comparing HTML:

  context "(on fragments consisting of multiple nodes)" do
    it "should compare all nodes" do
      doc1 = "<h1>Headline</h1><h1>Headline</h1>"
      doc2 = "<h1>Headline</h1><h2>Headline2</h2>"
      expect(doc1).not_to be_equivalent_to(doc2)
    end
  end

So if you need equivalient-xml to handle invalid XML strings, you're left with NOENT. Unfortunately, I don't see any way to use parsing options with Nokogiri::XML#fragment (here), that's why I haven't opened a PR, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant