Skip to content

Commit f3f5f6e

Browse files
authored
Merge pull request github#12190 from erik-krogh/fix-erb
JS: Actually extract `.html.erb` files.
2 parents 734001b + 505168f commit f3f5f6e

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

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

Lines changed: 7 additions & 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", ".html.erb") {
107+
HTML(".htm", ".html", ".xhtm", ".xhtml", ".vue", ".hbs", ".ejs", ".njk", ".erb") {
108108
@Override
109109
public IExtractor mkExtractor(ExtractorConfig config, ExtractorState state) {
110110
return new HTMLExtractor(config, state);
@@ -120,6 +120,12 @@ protected boolean contains(File f, String lcExt, ExtractorConfig config) {
120120
if (isBinaryFile(f, lcExt, config)) {
121121
return false;
122122
}
123+
// for ERB files we are only interrested in `.html.erb` files
124+
if (FileUtil.extension(f).equalsIgnoreCase(".erb")) {
125+
if (!f.getName().toLowerCase().endsWith(".html.erb")) {
126+
return false;
127+
}
128+
}
123129
return super.contains(f, lcExt, config);
124130
}
125131
},

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-29";
44+
public static final String EXTRACTOR_VERSION = "2023-02-15";
4545

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

javascript/extractor/tests/vue/output/trap/rails.html.erb.trap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#10000=@"/rails.erb;sourcefile"
2-
files(#10000,"/rails.erb")
1+
#10000=@"/rails.html.erb;sourcefile"
2+
files(#10000,"/rails.html.erb")
33
#10001=@"/;folder"
44
folders(#10001,"/")
55
containerparent(#10001,#10000)

0 commit comments

Comments
 (0)