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

Unhandled espaced quote on attributes #217

Open
llafuente opened this issue Jul 13, 2017 · 2 comments
Open

Unhandled espaced quote on attributes #217

llafuente opened this issue Jul 13, 2017 · 2 comments

Comments

@llafuente
Copy link

Hi,

<x value="evil is \"inside"></x> is not parsed properly (to my HTML eyes at least ^^)

I expect to have an attribute with value with value evil is "inside
Instead sax found two attributes, also report some erorrs, due not handling \"

TEST

const sax = require("../sax/sax.js");
const parser = sax.parser(true, {
  lowercase: true,
  //strictEntities : true
});
parser.onerror = console.log.bind(console);
parser.onopentag = console.log.bind(console);
parser.onclosetag = console.log.bind(console);
parser.onend = console.log.bind(console);

parser.write(`<x value="evil is \"inside"></x>`).close();
output:
Line: 0
Column: 20
Char: i
    at error (C:\Users\xe64758\Documents\GitHub\html-formatter\sax\sax.js:667:10)
    at strictFail (C:\Users\xe64758\Documents\GitHub\html-formatter\sax\sax.js:693:7)
    at Object.write (C:\Users\xe64758\Documents\GitHub\html-formatter\sax\sax.js:1411:13)
    at Object.<anonymous> (C:\Users\xe64758\Documents\GitHub\html-formatter\test\test.js:464:8)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:393:7)
    at startup (bootstrap_node.js:150:9)
    at bootstrap_node.js:508:3
Error: Invalid attribute name
Line: 0
Column: 26
Char: "
    at error (C:\Users\xe64758\Documents\GitHub\html-formatter\sax\sax.js:667:10)
    at strictFail (C:\Users\xe64758\Documents\GitHub\html-formatter\sax\sax.js:693:7)
    at Object.write (C:\Users\xe64758\Documents\GitHub\html-formatter\sax\sax.js:1346:13)
    at Object.<anonymous> (C:\Users\xe64758\Documents\GitHub\html-formatter\test\test.js:464:8)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:393:7)
    at startup (bootstrap_node.js:150:9)
    at bootstrap_node.js:508:3
Error: Attribute without value
Line: 0
Column: 27
Char: >
    at error (C:\Users\xe64758\Documents\GitHub\html-formatter\sax\sax.js:667:10)
    at strictFail (C:\Users\xe64758\Documents\GitHub\html-formatter\sax\sax.js:693:7)
    at Object.write (C:\Users\xe64758\Documents\GitHub\html-formatter\sax\sax.js:1337:13)
    at Object.<anonymous> (C:\Users\xe64758\Documents\GitHub\html-formatter\test\test.js:464:8)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:393:7)
    at startup (bootstrap_node.js:150:9)
    at bootstrap_node.js:508:3
{ name: 'x',
  attributes: { value: 'evil is ', inside: 'inside' },
  isSelfClosing: false }
x
@michaelnisi
Copy link

Ouch! That‘s bad, not to say evil. Is this with attributes or in general? <x>"evil is \"inside"</x>.

@brianmjerome
Copy link

I'm running into this issue trying to parse a JSON string value:
...<data>{"USER":[{"NAME":"Bar, Foo<span class=\"icon\">User</span>"}]}</data>...
I get the error pointing to the \".

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

3 participants