Skip to content

Commit 6f4fd3e

Browse files
authored
Merge pull request github#11175 from erik-krogh/erb
JS: extract .erb files as html
2 parents d79c722 + cec5045 commit 6f4fd3e

File tree

5 files changed

+143
-3
lines changed

5 files changed

+143
-3
lines changed

javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
* <li>All JavaScript files, that is, files with one of the extensions supported by {@link
142142
* FileType#JS} (currently ".js", ".jsx", ".mjs", ".cjs", ".es6", ".es").
143143
* <li>All HTML files, that is, files with with one of the extensions supported by {@link
144-
* FileType#HTML} (currently ".htm", ".html", ".xhtm", ".xhtml", ".vue").
144+
* FileType#HTML} (currently ".htm", ".html", ".xhtm", ".xhtml", ".vue", ".html.erb").
145145
* <li>All YAML files, that is, files with one of the extensions supported by {@link
146146
* FileType#YAML} (currently ".raml", ".yaml", ".yml").
147147
* <li>Files with base name "package.json" or "tsconfig.json", and files whose base name

javascript/extractor/src/com/semmle/js/extractor/FileExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private static int skipBOM(byte[] bytes, int length) {
104104

105105
/** Information about supported file types. */
106106
public static enum FileType {
107-
HTML(".htm", ".html", ".xhtm", ".xhtml", ".vue", ".hbs", ".ejs", ".njk") {
107+
HTML(".htm", ".html", ".xhtm", ".xhtml", ".vue", ".hbs", ".ejs", ".njk", ".html.erb") {
108108
@Override
109109
public IExtractor mkExtractor(ExtractorConfig config, ExtractorState state) {
110110
return new HTMLExtractor(config, state);

javascript/extractor/src/com/semmle/js/extractor/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class Main {
4141
* A version identifier that should be updated every time the extractor changes in such a way that
4242
* it may produce different tuples for the same file under the same {@link ExtractorConfig}.
4343
*/
44-
public static final String EXTRACTOR_VERSION = "2022-11-14";
44+
public static final String EXTRACTOR_VERSION = "2022-11-15";
4545

4646
public static final Pattern NEWLINE = Pattern.compile("\n");
4747

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<script>
2+
console.log("FOO");
3+
</script>
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
#10000=@"/rails.erb;sourcefile"
2+
files(#10000,"/rails.erb")
3+
#10001=@"/;folder"
4+
folders(#10001,"/")
5+
containerparent(#10001,#10000)
6+
#10002=@"loc,{#10000},0,0,0,0"
7+
locations_default(#10002,#10000,0,0,0,0)
8+
hasLocation(#10000,#10002)
9+
#20000=@"global_scope"
10+
scopes(#20000,0)
11+
#20001=*
12+
#20002=@"script;{#10000},1,9"
13+
#20003=*
14+
lines(#20003,#20002,"","
15+
")
16+
#20004=@"loc,{#10000},1,9,1,8"
17+
locations_default(#20004,#10000,1,9,1,8)
18+
hasLocation(#20003,#20004)
19+
#20005=*
20+
lines(#20005,#20002," console.log(""FOO"");","
21+
")
22+
#20006=@"loc,{#10000},2,1,2,21"
23+
locations_default(#20006,#10000,2,1,2,21)
24+
hasLocation(#20005,#20006)
25+
indentation(#10000,2," ",2)
26+
numlines(#20002,2,1,0)
27+
#20007=*
28+
tokeninfo(#20007,6,#20002,0,"console")
29+
#20008=@"loc,{#10000},2,3,2,9"
30+
locations_default(#20008,#10000,2,3,2,9)
31+
hasLocation(#20007,#20008)
32+
#20009=*
33+
tokeninfo(#20009,8,#20002,1,".")
34+
#20010=@"loc,{#10000},2,10,2,10"
35+
locations_default(#20010,#10000,2,10,2,10)
36+
hasLocation(#20009,#20010)
37+
#20011=*
38+
tokeninfo(#20011,6,#20002,2,"log")
39+
#20012=@"loc,{#10000},2,11,2,13"
40+
locations_default(#20012,#10000,2,11,2,13)
41+
hasLocation(#20011,#20012)
42+
#20013=*
43+
tokeninfo(#20013,8,#20002,3,"(")
44+
#20014=@"loc,{#10000},2,14,2,14"
45+
locations_default(#20014,#10000,2,14,2,14)
46+
hasLocation(#20013,#20014)
47+
#20015=*
48+
tokeninfo(#20015,4,#20002,4,"""FOO""")
49+
#20016=@"loc,{#10000},2,15,2,19"
50+
locations_default(#20016,#10000,2,15,2,19)
51+
hasLocation(#20015,#20016)
52+
#20017=*
53+
tokeninfo(#20017,8,#20002,5,")")
54+
#20018=@"loc,{#10000},2,20,2,20"
55+
locations_default(#20018,#10000,2,20,2,20)
56+
hasLocation(#20017,#20018)
57+
#20019=*
58+
tokeninfo(#20019,8,#20002,6,";")
59+
#20020=@"loc,{#10000},2,21,2,21"
60+
locations_default(#20020,#10000,2,21,2,21)
61+
hasLocation(#20019,#20020)
62+
#20021=*
63+
tokeninfo(#20021,0,#20002,7,"")
64+
#20022=@"loc,{#10000},3,1,3,0"
65+
locations_default(#20022,#10000,3,1,3,0)
66+
hasLocation(#20021,#20022)
67+
toplevels(#20002,1)
68+
#20023=@"loc,{#10000},1,9,3,0"
69+
locations_default(#20023,#10000,1,9,3,0)
70+
hasLocation(#20002,#20023)
71+
#20024=*
72+
stmts(#20024,2,#20002,0,"console.log(""FOO"");")
73+
#20025=@"loc,{#10000},2,3,2,21"
74+
locations_default(#20025,#10000,2,3,2,21)
75+
hasLocation(#20024,#20025)
76+
stmt_containers(#20024,#20002)
77+
#20026=*
78+
exprs(#20026,13,#20024,0,"console.log(""FOO"")")
79+
#20027=@"loc,{#10000},2,3,2,20"
80+
locations_default(#20027,#10000,2,3,2,20)
81+
hasLocation(#20026,#20027)
82+
enclosing_stmt(#20026,#20024)
83+
expr_containers(#20026,#20002)
84+
#20028=*
85+
exprs(#20028,14,#20026,-1,"console.log")
86+
#20029=@"loc,{#10000},2,3,2,13"
87+
locations_default(#20029,#10000,2,3,2,13)
88+
hasLocation(#20028,#20029)
89+
enclosing_stmt(#20028,#20024)
90+
expr_containers(#20028,#20002)
91+
#20030=*
92+
exprs(#20030,79,#20028,0,"console")
93+
hasLocation(#20030,#20008)
94+
enclosing_stmt(#20030,#20024)
95+
expr_containers(#20030,#20002)
96+
literals("console","console",#20030)
97+
#20031=@"var;{console};{#20000}"
98+
variables(#20031,"console",#20000)
99+
bind(#20030,#20031)
100+
#20032=*
101+
exprs(#20032,0,#20028,1,"log")
102+
hasLocation(#20032,#20012)
103+
enclosing_stmt(#20032,#20024)
104+
expr_containers(#20032,#20002)
105+
literals("log","log",#20032)
106+
#20033=*
107+
exprs(#20033,4,#20026,0,"""FOO""")
108+
hasLocation(#20033,#20016)
109+
enclosing_stmt(#20033,#20024)
110+
expr_containers(#20033,#20002)
111+
literals("FOO","""FOO""",#20033)
112+
#20034=*
113+
regexpterm(#20034,14,#20033,0,"FOO")
114+
#20035=@"loc,{#10000},2,16,2,18"
115+
locations_default(#20035,#10000,2,16,2,18)
116+
hasLocation(#20034,#20035)
117+
regexp_const_value(#20034,"FOO")
118+
#20036=*
119+
entry_cfg_node(#20036,#20002)
120+
hasLocation(#20036,#20004)
121+
#20037=*
122+
exit_cfg_node(#20037,#20002)
123+
hasLocation(#20037,#20022)
124+
successor(#20024,#20030)
125+
successor(#20033,#20026)
126+
successor(#20032,#20028)
127+
successor(#20030,#20032)
128+
successor(#20028,#20033)
129+
successor(#20026,#20037)
130+
successor(#20036,#20024)
131+
toplevel_parent_xml_node(#20002,#20001)
132+
xmlElements(#20001,"script",#10000,0,#10000)
133+
#20038=@"loc,{#10000},1,1,3,9"
134+
locations_default(#20038,#10000,1,1,3,9)
135+
xmllocations(#20001,#20038)
136+
numlines(#10000,3,1,0)
137+
filetype(#10000,"html")

0 commit comments

Comments
 (0)