Skip to content

Commit 53ec7e0

Browse files
committed
Dont parse javascript < in script tags
1 parent 76529b3 commit 53ec7e0

File tree

7 files changed

+6798
-15
lines changed

7 files changed

+6798
-15
lines changed

.jshintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"curly": true,
33
"latedef": true,
4-
"quotmark": true,
54
"undef": true,
65
"unused": true,
76
"trailing": true,

lib/parse-tag.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var attrRE = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g
1+
var attrRE = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;
22

33
// create optimized lookup object for
44
// void elements as listed here:
@@ -30,40 +30,45 @@ module.exports = function (tag) {
3030
children: []
3131
};
3232

33-
let tagMatch = tag.match(/<\/?([^\s]+?)[/\s>]/)
33+
var tagMatch = tag.match(/<\/?([^\s]+?)[/\s>]/);
3434
if(tagMatch)
3535
{
3636
res.name = tagMatch[1];
37-
if (lookup[tagMatch[1].toLowerCase()] || tag.charAt(tag.length - 2) === '/')
37+
if (lookup[tagMatch[1].toLowerCase()] || tag.charAt(tag.length - 2) === '/') {
3838
res.voidElement = true;
39+
}
3940

4041
}
4142

42-
let reg = new RegExp(attrRE)
43-
let result = null;
43+
var reg = new RegExp(attrRE);
44+
var result = null;
4445
for (; ;)
4546
{
4647
result = reg.exec(tag);
4748

48-
if (result === null)
49+
if (result === null) {
4950
break;
51+
}
5052

51-
if (!result[0].trim())
53+
if (!result[0].trim()) {
5254
continue;
55+
}
5356

5457
if (result[1])
5558
{
56-
let attr = result[1].trim();
57-
let arr = [attr, ""];
59+
var attr = result[1].trim();
60+
var arr = [attr, ''];
5861

59-
if(attr.indexOf("=") > -1)
60-
arr = attr.split("=");
62+
if(attr.indexOf('=') > -1) {
63+
arr = attr.split('=');
64+
}
6165

6266
res.attrs[arr[0]] = arr[1];
6367
reg.lastIndex--;
6468
}
65-
else if (result[2])
69+
else if (result[2]) {
6670
res.attrs[result[2]] = result[3].trim().substring(1,result[3].length - 1);
71+
}
6772
}
6873

6974
return res;

lib/parse.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*jshint -W030 */
2-
var tagRE = /<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>/g;
2+
var tagRE = /<[a-zA-Z\-\!\/](?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])*>/g;
3+
34
var parseTag = require('./parse-tag');
45
// re-used obj for quick lookups of components
56
var empty = Object.create ? Object.create(null) : {};

0 commit comments

Comments
 (0)