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

Incorrectly parsing JSON when using innerText with < #71

Closed
figueiredo-lucas opened this issue Oct 31, 2017 · 2 comments
Closed

Incorrectly parsing JSON when using innerText with < #71

figueiredo-lucas opened this issue Oct 31, 2017 · 2 comments

Comments

@figueiredo-lucas
Copy link

Hello,

I'm facing a problem in my code where some input made by an user have < and/or >.

As i tested, my input is:

"<span class=""> >30 days and <= 120 days </span>"

and the json parser transforms it in:

{
    "type": "Element",
    "tagName": "span",
    "attributes": {
        "className": [
            ""
        ]
    },
    "children": [
        {
            "type": "Text",
            "content": "\n    \n        >30 days and "
        },
        {
            "type": "Element",
            "tagName": "=",
            "attributes": {
                "120": 120,
                "days": "days",
                "<": "<"
            },
            "children": []
        },
        {
            "type": "Text",
            "content": "pan>"
        }
    ]
}

That's a pretty specific scenario and anyways I already have a workaround for it. Just reported it so it could be tracked and later on fixed.

Thanks in advance!

@andrejewski
Copy link
Owner

I looked into this. My first reaction was that your < needed to be escaped, however looking at the spec for HTML5 tag names it appears only alphanumeric ascii characters are allowed. This means I can improve the parser for this case. However this introduces a new problem: the dash - is not an alphanumeric character which is used by many people for web/custom components. The question is where I draw the line when deviating from the spec.

@figueiredo-lucas
Copy link
Author

The workaround I did was exactly that. As I said, it is a pretty specific scenario that does not happen very often (I've been using himalaya for nearly a year and it was the first time).
About the dash, unfortunately it looks like each case might need to be treated differently. By now, the dash is the only character deviating from the spec, right?

Thanks for the reply and the effort!

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

2 participants