Skip to content

Prevent hyperlink handler for potential dangerous URIs #850

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

Merged
merged 1 commit into from
Jan 8, 2015
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ See also section about WebODF

* Fix wrongly enabled hyperlink tools with no document loaded ([#833](https://github.com/kogmbh/WebODF/pull/833))
* Prevent Cross-Site Scripting from style names and font names ([#849](https://github.com/kogmbh/WebODF/pull/849)))
* Avoid badly rendered toolbar element with subsets of tools ([#849](https://github.com/kogmbh/WebODF/pull/855)))
* Avoid badly rendered toolbar element with subsets of tools ([#855](https://github.com/kogmbh/WebODF/pull/855)))
* Prevent Cross-Site Scripting from links ([#850](https://github.com/kogmbh/WebODF/pull/850)))

# Changes between 0.5.3 and 0.5.4

Expand Down
9 changes: 7 additions & 2 deletions webodf/lib/gui/HyperlinkClickHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,13 @@ gui.HyperlinkClickHandler = function HyperlinkClickHandler(getContainer, keyDown
bookmarks[0].scrollIntoView(true);
}
} else {
// Ask the browser to open the link in a new window.
window.open(url);
// Ask the browser to open the link in a new window. `javascript` and `data` URIs are disabled for
// security reasons.
if(/^\s*(javascript|data):/.test(url)) {
runtime.log("WARN:", "potentially malicious URL ignored");
} else {
window.open(url);
}
}

if (e.preventDefault) {
Expand Down