diff options
| author | Dan Fandrich <danf@mageia.org> | 2025-05-23 23:29:32 -0700 |
|---|---|---|
| committer | Dan Fandrich <danf@mageia.org> | 2025-05-23 23:29:32 -0700 |
| commit | 913c507f2bfc8e9f3de463e8bae0cfcbaad14fd7 (patch) | |
| tree | 8f1f2c206541b57c1c2802f340bd14acab1db338 | |
| parent | 4687b88f87b303e15b0ce42b62cf0279d499c8ea (diff) | |
| download | puppet-913c507f2bfc8e9f3de463e8bae0cfcbaad14fd7.tar puppet-913c507f2bfc8e9f3de463e8bae0cfcbaad14fd7.tar.gz puppet-913c507f2bfc8e9f3de463e8bae0cfcbaad14fd7.tar.bz2 puppet-913c507f2bfc8e9f3de463e8bae0cfcbaad14fd7.tar.xz puppet-913c507f2bfc8e9f3de463e8bae0cfcbaad14fd7.zip | |
Use an absolute URL when redirecting
This reduces the possibility of a malicious URL redirecting to another
domain.
| -rw-r--r-- | modules/viewvc/files/setcookieredirect.html | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/modules/viewvc/files/setcookieredirect.html b/modules/viewvc/files/setcookieredirect.html index 3adefed2..acb34af6 100644 --- a/modules/viewvc/files/setcookieredirect.html +++ b/modules/viewvc/files/setcookieredirect.html @@ -8,10 +8,11 @@ const params = new Proxy(new URLSearchParams(window.location.search), { get: (searchParams, prop) => searchParams.get(prop), }); - let url = params.to; + let path = params.to; // Sanitize redirect path to avoid malicious arbitrary redirects - if (/^\/[-a-zA-Z0-9~_.?&=/+]*$/.test(url)) { - window.location.href = url; + if (/^\/[-a-zA-Z0-9~_.?&=/+]*$/.test(path)) { + const current = new URL(window.location.toLocaleString()); + window.location.href = current.origin + path; } else { window.onload = function() { document.getElementById('error').innerHTML = 'Error! Bad redirect location!'; |
