Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update frames.erb for better XSS check #1538

Merged
merged 3 commits into from
Feb 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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