JSLint正则expression式违规Quandry
我有以下的正则expression
/\<oauth_token\>([^\<]*)\<\/oauth_token\>/
我看到jslint侵犯了非转义<字符,但不能解决原因。 有谁能够赐教我吗?
这个正则expression式被分配给一个variables,并在整个文件中被使用。 它在一个nodejs模块中。
这是一个绕开一个不符合标准的OAUth响应的攻击,将来会在某个时刻被修复。 我不想把XMLparsing器作为额外的依赖来解决这个问题。
我看到这违反与JSHint和node-jslint。
你可以在github上看到文件的完整源代码JSHint的确切输出如下:
lib/oauth-helper.js: line 5, col 21, Unexpected escaped character '<' in regular expression. lib/oauth-helper.js: line 5, col 39, Unexpected escaped character '<' in regular expression. lib/oauth-helper.js: line 5, col 44, Unexpected escaped character '<' in regular expression. lib/oauth-helper.js: line 6, col 22, Unexpected escaped character '<' in regular expression. lib/oauth-helper.js: line 6, col 47, Unexpected escaped character '<' in regular expression. lib/oauth-helper.js: line 6, col 52, Unexpected escaped character '<' in regular expression.
没有必要在正则expression式中转义“<”字符。 这就是JSLint告诉你的 – 模式中的“<”字符之前的反斜杠是不必要的。