JS: support <meta name="generator"/> classification

This commit is contained in:
Esben Sparre Andreasen
2018-12-11 09:12:39 +01:00
parent a295dfd2c5
commit 3879e57f18
7 changed files with 67 additions and 2 deletions

View File

@@ -114,6 +114,17 @@ private predicate isData(File f) {
)
}
/**
* Holds if `f` is a generated HTML file.
*/
private predicate isGeneratedHtml(File f) {
exists(HTML::Element e |
e.getFile() = f and
e.getName() = "meta" and
e.getAttributeByName("name").getValue() = "generator"
)
}
/**
* Holds if `tl` looks like it contains generated code.
*/
@@ -124,12 +135,14 @@ predicate isGenerated(TopLevel tl) {
tl instanceof DartGeneratedTopLevel or
exists (GeneratedCodeMarkerComment gcmc | tl = gcmc.getTopLevel()) or
hasManyInvocations(tl) or
isData(tl.getFile())
isData(tl.getFile()) or
isGeneratedHtml(tl.getFile())
}
/**
* Holds if `file` look like it contains generated code.
*/
predicate isGeneratedCode(File file) {
isGenerated(file.getATopLevel())
isGenerated(file.getATopLevel()) or
isGeneratedHtml(file)
}

View File

@@ -2,7 +2,9 @@
| ai.1.2.3-build0123.js:0:0:0:0 | ai.1.2.3-build0123.js | library |
| bundle-directive.js:0:0:0:0 | bundle-directive.js | generated |
| data.js:0:0:0:0 | data.js | generated |
| etherpad.html:0:0:0:0 | etherpad.html | generated |
| exported-data.js:0:0:0:0 | exported-data.js | generated |
| htmltidy.html:0:0:0:0 | htmltidy.html | generated |
| jison-lex.js:0:0:0:0 | jison-lex.js | generated |
| jison.js:0:0:0:0 | jison.js | generated |
| jquery-datatables.js:0:0:0:0 | jquery-datatables.js | library |
@@ -15,10 +17,13 @@
| multiple-licenses-2.js:0:0:0:0 | multiple-licenses-2.js | generated |
| multiple-licenses.js:0:0:0:0 | multiple-licenses.js | generated |
| opal-test.js:0:0:0:0 | opal-test.js | generated |
| orgmode.html:0:0:0:0 | orgmode.html | generated |
| pandoc.html:0:0:0:0 | pandoc.html | generated |
| peg-js.js:0:0:0:0 | peg-js.js | generated |
| polymer.html:0:0:0:0 | polymer.html | template |
| some-template.html:0:0:0:0 | some-template.html | template |
| templ.js:0:0:0:0 | templ.js | template |
| textmate.html:0:0:0:0 | textmate.html | generated |
| tmpl2.html:0:0:0:0 | tmpl2.html | template |
| tmpl.html:0:0:0:0 | tmpl.html | template |
| tst.browserify.js:0:0:0:0 | tst.browserify.js | generated |

View File

@@ -0,0 +1,10 @@
<!doctype html>
<html lang="en">
<head>
<title><%- padId %></title>
<meta name="generator" content="Etherpad">
<script type="text/javascript">//</script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,9 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy for Linux/x86 (vers 25 March 2009), see www.w3.org">
<script type="text/javascript">//</script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta name="generator" content="Org-mode"/>
<script type="text/javascript">//</script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<head>
<meta name="generator" content="pandoc" />
<script type="text/javascript">//</script>
</head>
<body>
</html>

View File

@@ -0,0 +1,9 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta name="generator" content="TextMate http://macromates.com/">
<script type="text/javascript">//</script>
</head>
<body>
</html>