Skip to content

Commit

Permalink
Merge pull request #1538 from RedYetiDev/patch-2
Browse files Browse the repository at this point in the history
Update frames.erb for better XSS check
  • Loading branch information
lsegal authored Feb 29, 2024
2 parents 3059017 + a831a59 commit 1fcb2d8
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions templates/default/fulldoc/html/frames.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
<title><%= options.title %></title>
</head>
<script type="text/javascript">
var match = decodeURIComponent(window.location.hash).match(/^#!(.+)/);
var name = match ? match[1] : '<%= url_for_main %>';
name = name.replace(/^((\w*):)?[\/\\]*/gm, '').trim();
window.top.location.replace(name)
var mainUrl = '<%= url_for_main %>';
try {
var match = decodeURIComponent(window.location.hash).match(/^#!(.+)/);
var name = match ? match[1] : mainUrl;
var url = new URL(name, location.href);
window.top.location.replace(url.origin === location.origin ? name : mainUrl);
} catch (e) {
window.top.location.replace(mainUrl);
}
</script>
<noscript>
<h1>Oops!</h1>
Expand Down

0 comments on commit 1fcb2d8

Please sign in to comment.