Skip to content

Commit eadaed1

Browse files
authored
Merge pull request #30 from pconerly/dont-parse-javascript-script-content-as-tag
Dont parse javascript script content "<" as tag
2 parents 76529b3 + 04f2e32 commit eadaed1

File tree

8 files changed

+6832
-15
lines changed

8 files changed

+6832
-15
lines changed

.circleci/config.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Javascript Node CircleCI 2.0 configuration file
2+
#
3+
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
4+
#
5+
version: 2.1
6+
jobs:
7+
build:
8+
docker:
9+
# - image: circleci/node:8.9.4
10+
- image: circleci/node:8.16.0
11+
12+
working_directory: ~/project
13+
14+
steps:
15+
- checkout
16+
17+
# Download and cache dependencies
18+
- restore_cache:
19+
keys:
20+
- deps-{{ checksum "package-lock.json" }}
21+
# fallback to using the latest cache if no exact match is found
22+
- deps-
23+
24+
- run: npm install
25+
26+
- save_cache:
27+
paths:
28+
- frontend/node_modules
29+
key: deps-{{ checksum "package-lock.json" }}
30+
31+
# run tests
32+
- run: npm run test-node
33+
# run lint
34+
- run: npm run jshint

.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)