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

Parenthesis and asterisk trigger parsing errors #100

Closed
floo51 opened this issue Nov 29, 2015 · 15 comments
Closed

Parenthesis and asterisk trigger parsing errors #100

floo51 opened this issue Nov 29, 2015 · 15 comments

Comments

@floo51
Copy link

floo51 commented Nov 29, 2015

Angular 2 introduces a new syntax for attributes which can lead to this :

<li *ng-for="#item of collection">
  <button (click)="action(item)">Do something</button>
</li>

This is plain valid HTML but it triggers those 2 errors :

  • Special characters must be escaped
  • Tag must be paired
@yaniswang
Copy link
Contributor

HTMLHint only support HTML code, your angular code is template, no supported.

@saeidzebardast
Copy link

Same problem in Polymer when using $ in attribute name:

  • ([</div>] Tag must pair)
<div id$="[[myId]]">
  <content></content>
</div>

@floo51
Copy link
Author

floo51 commented Feb 5, 2016

Taken from the W3C HTML specification :

Attribute names must consist of one or more characters other than the space characters, U+0000 NULL, """, "'", ">", "/", "=", the control characters, and any characters that are not defined by Unicode.

Following this rule, the code <div my*attribute="" *ng-for="" id$=""></div> is totally valid.

@szabyg
Copy link

szabyg commented Feb 23, 2016

+1 We would need this as well.
Any implementation hints, ideas, workaround?

@the-ult
Copy link

the-ult commented Feb 24, 2016

+1

@david-gang
Copy link

Hi @yaniswang ,

The issue is with the regular expression at: https://github.com/yaniswang/HTMLHint/blob/master/src/htmlparser.js#L36-L38

If we could make them unicode aware, we would solve the issue.

There are already projects working with regular expression and unicode like https://github.com/slevithan/xregexp

What do you think about this approach?

@mochtu
Copy link

mochtu commented Mar 17, 2016

+1

@Zorgatone
Copy link

+1:+1:

@felixfbecker
Copy link

This is a serious bug... In a nutshell HTMLHint throwing errors on valid HTML. Can we please get a fix for this?

@Zorgatone
Copy link

I totally agree @felixfbecker

@felixfbecker
Copy link

felixfbecker commented Apr 30, 2016

Instead of whitelisting characters here

/\s*([\w\-:]+)(?:\s*=\s*(?:(")([^"]*)"|(')([^']*)'|([^\s"'>]*)))?/

it should use an inverted character class that includes anything but "'>/=, NULL and whitespace:

/\s*([^"'>/=\0\s]+)(?:\s*=\s*(?:(")([^"]*)"|(')([^']*)'|([^\s"'>]*)))?/

Element tag names are not affected (see W3C)

@felixfbecker
Copy link

Made a PR

@yaniswang
Copy link
Contributor

Fixed now: b6a4d1a

@aaawhz
Copy link

aaawhz commented Sep 13, 2017

加上jsp语法吧, 我们很多页面都是用jsp写的。。。

@Zorgatone
Copy link

So is this really parsing HTML using Regular Expressions?
21414757_814231438744575_8699813647299847613_o

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

10 participants