Skip to content

Commit 7434c41

Browse files
wchargingkdn
authored andcommitted
WebfilesValidator: whitelist mailto: URLs (#383)
This patch teaches `WebfilesValidator` that `mailto:` URLs don’t express webfiles dependency relationships, and so do not need to be accompanied by a `web_library` provider. See: <tensorflow/tensorboard#2297> Test Plan: Unit test added; it fails before this change and passes after it.
1 parent 442f3c0 commit 7434c41

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

java/io/bazel/rules/closure/webfiles/WebfilesValidator.java

+1
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ private static boolean shouldIgnoreUri(String uri) {
216216
|| uri.contains("//")
217217
|| uri.startsWith("data:")
218218
|| uri.startsWith("javascript:")
219+
|| uri.startsWith("mailto:")
219220
|| uri.equals("about:blank")
220221
// The following are intended to filter out URLs with Polymer variables.
221222
|| (uri.contains("[[") && uri.contains("]]"))

javatests/io/bazel/rules/closure/webfiles/WebfilesValidatorTest.java

+16
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,22 @@ public void dataUris_getIgnored() throws Exception {
205205
.isEmpty();
206206
}
207207

208+
@Test
209+
public void mailtoUris_getIgnored() throws Exception {
210+
save(fs.getPath("/fs/path/index.html"), "<a href=\"mailto:[email protected]\">email us</a>\n");
211+
assertThat(
212+
validator.validate(
213+
Webfiles.newBuilder()
214+
.addSrc(WebfilesSource.newBuilder()
215+
.setPath("/fs/path/index.html")
216+
.setWebpath("/web/path/index.html")
217+
.build())
218+
.build(),
219+
ImmutableList.<Webfiles>of(),
220+
Suppliers.ofInstance(ImmutableList.<Webfiles>of())))
221+
.isEmpty();
222+
}
223+
208224
@Test
209225
public void cssUrls_areRecognized() throws Exception {
210226
save(fs.getPath("/fs/path/index.html"), "<link rel=\"stylesheet\" href=\"index.css\">");

0 commit comments

Comments
 (0)