Skip to content

Commit

Permalink
Add IgnoreURL logic to enforceHTTPS
Browse files Browse the repository at this point in the history
Will fix #94
  • Loading branch information
wjdp committed Sep 5, 2018
1 parent 8200c4e commit 3616984
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
5 changes: 5 additions & 0 deletions htmltest/check-generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ func (hT *HTMLTest) checkGenericRef(ref *htmldoc.Reference) {
}

func (hT *HTMLTest) enforceHTTPS(ref *htmldoc.Reference) {
// Does this url match an url ignore rule?
if hT.opts.isURLIgnored(ref.URLString()) {
return
}

if hT.opts.EnforceHTTPS {
hT.issueStore.AddIssue(issues.Issue{
Level: issues.LevelError,
Expand Down
11 changes: 10 additions & 1 deletion htmltest/check-link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func TestAnchorIgnorableChildren(t *testing.T) {
tExpectIssueCount(t, hT, 0)
}


func TestAnchorMatchIgnore(t *testing.T) {
// ignores links in IgnoreURLs
hT := tTestFileOpts("fixtures/links/brokenLinkExternalSingle.html",
Expand Down Expand Up @@ -104,6 +103,16 @@ func TestAnchorExternalInsecureOption(t *testing.T) {
tExpectIssue(t, hT, "is not an HTTPS target", 1)
}

func TestAnchorExternalInsecureOptionIgnored(t *testing.T) {
// passes when checking for non-HTTPS links but they're in the IgnoreURLs list
hT := tTestFileOpts("fixtures/links/issues/94.html",
map[string]interface{}{
"EnforceHTTPS": true,
"IgnoreURLs": []interface{}{"plantuml.com", "plantuml.net", "forum.plantuml.net"},
})
tExpectIssueCount(t, hT, 0)
}

func TestAnchorExternalHrefIP(t *testing.T) {
// fails for broken IP address links
hT := tTestFileOpts("fixtures/links/ip_href.html",
Expand Down
11 changes: 11 additions & 0 deletions htmltest/fixtures/links/issues/94.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<meta http-equiv="refresh" content="3; url=http://forum.plantuml.net/3448/how-to-display-nested-tree-like-structure-in-a-class-body?show=3455#a3455">

<link type="text/css" href="http://forum.plantuml.net/44044.css">

<a href="http://forum.plantuml.net/3448/how-to-display-nested-tree-like-structure-in-a-class-body?show=3455#a3455">Source</a>
<a href="http://plantuml.net/class-diagram">http://plantuml.com/class-diagram</a>
<p><a href="http://forum.plantuml.net/7530/how-to-create-a-diagram-with-unconnected-nested-blocks?show=7531#a7531">Source</a>
</p>
<a href="http://forum.plantuml.net/7537/specify-nested-rectangles-to-be-created-in-vertical-order?show=7545#a7545">Source</a>

<script src="http://plantuml.com/scripty.js"></script>

0 comments on commit 3616984

Please sign in to comment.