Skip to content

Commit

Permalink
WebfilesValidator: whitelist mailto: URLs (#383)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wchargin authored and gkdn committed Jun 5, 2019
1 parent 442f3c0 commit 7434c41
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ private static boolean shouldIgnoreUri(String uri) {
|| uri.contains("//")
|| uri.startsWith("data:")
|| uri.startsWith("javascript:")
|| uri.startsWith("mailto:")
|| uri.equals("about:blank")
// The following are intended to filter out URLs with Polymer variables.
|| (uri.contains("[[") && uri.contains("]]"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,22 @@ public void dataUris_getIgnored() throws Exception {
.isEmpty();
}

@Test
public void mailtoUris_getIgnored() throws Exception {
save(fs.getPath("/fs/path/index.html"), "<a href=\"mailto:[email protected]\">email us</a>\n");
assertThat(
validator.validate(
Webfiles.newBuilder()
.addSrc(WebfilesSource.newBuilder()
.setPath("/fs/path/index.html")
.setWebpath("/web/path/index.html")
.build())
.build(),
ImmutableList.<Webfiles>of(),
Suppliers.ofInstance(ImmutableList.<Webfiles>of())))
.isEmpty();
}

@Test
public void cssUrls_areRecognized() throws Exception {
save(fs.getPath("/fs/path/index.html"), "<link rel=\"stylesheet\" href=\"index.css\">");
Expand Down

0 comments on commit 7434c41

Please sign in to comment.