Skip to content

Commit 273d9b5

Browse files
authored
SONARHTML-174 Fix NPE in S4084 VideoTrackCheck (#246)
1 parent 155f558 commit 273d9b5

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

sonar-html-plugin/src/main/java/org/sonar/plugins/html/checks/sonar/VideoTrackCheck.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ private static boolean isSourceTag(TagNode node) {
6161
}
6262

6363
private static boolean isAccessibilityTrackTag(TagNode node) {
64-
return node.equalsElementName("TRACK") && ACCESSIBILITY_TRACK_KINDS.contains(node.getPropertyValue("KIND"));
64+
var kind = node.getPropertyValue("KIND");
65+
return node.equalsElementName("TRACK") && kind != null && ACCESSIBILITY_TRACK_KINDS.contains(kind);
6566
}
6667

6768
}

sonar-html-plugin/src/test/java/org/sonar/plugins/html/checks/sonar/VideoTrackCheckTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public void detected() {
3838
.next().atLine(33)
3939
.next().atLine(38)
4040
.next().atLine(43)
41-
.next().atLine(49);
41+
.next().atLine(49)
42+
.next().atLine(58);
4243
}
4344

4445
}

sonar-html-plugin/src/test/resources/checks/VideoTrackCheck.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,9 @@
5454
<track src="subtitles_en.vtt" [kind]="subtitles" srclang="en" label="English" />
5555
Your browser does not support HTML5 video.
5656
</video>
57+
58+
<video src="bla"> <!-- Non-Compliant -->
59+
<track src="" default>
60+
</video>
5761
</body>
5862
</html>

0 commit comments

Comments
 (0)