Skip to content

Commit 3cc6b11

Browse files
committed
JS: Expand attribute regex to include some Vue attributes
1 parent 560b3da commit 3cc6b11

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,9 @@ private boolean isAngularTemplateAttributeName(String name) {
184184
private static final Pattern ANGULAR_FOR_LOOP_DECL =
185185
Pattern.compile("^ *let +(\\w+) +of(?: +|(?!\\w))(.*)");
186186

187+
/** Attribute names that look valid in HTML or in one of the template languages we support, like Vue and Angular. */
187188
private static final Pattern VALID_ATTRIBUTE_NAME =
188-
Pattern.compile("\\*?\\[?\\(?[\\w:_\\-]+\\]?\\)?");
189+
Pattern.compile("[*:@]?\\[?\\(?[\\w:_\\-.]+\\]?\\)?");
189190

190191
/** List of HTML attributes whose value is interpreted as JavaScript. */
191192
private static final Pattern JS_ATTRIBUTE =

javascript/ql/test/library-tests/frameworks/Vue/tests.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,6 @@ attribute
175175
| single-file-component-3.vue:4:9:4:49 | src=./single-file-component-3-script.js | src |
176176
| single-file-component-4.vue:2:8:2:21 | v-html=dataA | v-html |
177177
| single-file-component-5.vue:2:8:2:21 | v-html=dataA | v-html |
178+
| special-syntax.vue:2:9:2:22 | :colonProp=x | :colonProp |
179+
| special-syntax.vue:2:24:2:34 | @atProp=x | @atProp |
180+
| special-syntax.vue:3:9:3:29 | :colonField.field=x | :colonField.field |

0 commit comments

Comments
 (0)