tsweb: add more test cases for TestCleanRedirectURL (#11331)

Updates #cleanup

Signed-off-by: Chris Palmer <cpalmer@tailscale.com>
pull/11334/head
Chris Palmer 9 months ago committed by GitHub
parent dff6f3377f
commit 13853e7f29
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -637,7 +637,6 @@ func TestCleanRedirectURL(t *testing.T) {
{"https://tailscale.com/foo", tailscaleHost, "https://tailscale.com/foo", false}, {"https://tailscale.com/foo", tailscaleHost, "https://tailscale.com/foo", false},
{"/foo", tailscaleHost, "/foo", false}, {"/foo", tailscaleHost, "/foo", false},
{"//tailscale.com/foo", tailscaleHost, "//tailscale.com/foo", false}, {"//tailscale.com/foo", tailscaleHost, "//tailscale.com/foo", false},
{"/a/foobar", tailscaleHost, "/a/foobar", false}, {"/a/foobar", tailscaleHost, "/a/foobar", false},
{"http://127.0.0.1/a/foobar", localHost, "http://127.0.0.1/a/foobar", false}, {"http://127.0.0.1/a/foobar", localHost, "http://127.0.0.1/a/foobar", false},
{"http://127.0.0.1:123/a/foobar", localHost, "http://127.0.0.1:123/a/foobar", false}, {"http://127.0.0.1:123/a/foobar", localHost, "http://127.0.0.1:123/a/foobar", false},
@ -650,6 +649,15 @@ func TestCleanRedirectURL(t *testing.T) {
{"http://myserver:31544/a/foobar", myServer, "http://myserver:31544/a/foobar", false}, {"http://myserver:31544/a/foobar", myServer, "http://myserver:31544/a/foobar", false},
{"http://evil.com/foo", tailscaleHost, "", true}, {"http://evil.com/foo", tailscaleHost, "", true},
{"//evil.com", tailscaleHost, "", true}, {"//evil.com", tailscaleHost, "", true},
{"\\\\evil.com", tailscaleHost, "", true},
{"javascript:alert(123)", tailscaleHost, "", true},
{"file:///", tailscaleHost, "", true},
{"file:////SERVER/directory/goats.txt", tailscaleHost, "", true},
{"https://google.com", tailscaleHost, "", true},
{"", tailscaleHost, "", false},
{"\"\"", tailscaleHost, "", true},
{"https://tailscale.com@goats.com:8443", tailscaleHost, "", true},
{"https://tailscale.com:8443@goats.com:8443", tailscaleHost, "", true},
{"HttP://tailscale.com", tailscaleHost, "http://tailscale.com", false}, {"HttP://tailscale.com", tailscaleHost, "http://tailscale.com", false},
{"http://TaIlScAlE.CoM/spongebob", tailscaleHost, "http://TaIlScAlE.CoM/spongebob", false}, {"http://TaIlScAlE.CoM/spongebob", tailscaleHost, "http://TaIlScAlE.CoM/spongebob", false},
{"ftp://tailscale.com", tailscaleHost, "", true}, {"ftp://tailscale.com", tailscaleHost, "", true},

Loading…
Cancel
Save