diff options
author | Waylan Limberg <waylan@gmail.com> | 2013-02-05 10:37:52 -0800 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2013-02-05 10:37:52 -0800 |
commit | 86381a43fe13a7c87e8a0b07c6117f1767b6acc0 (patch) | |
tree | d3f60375488b2d63bac3d24b0a41d1af3073e213 | |
parent | c201f3c706316fbafff51631ce86a0a3784f3218 (diff) | |
parent | f608517d9e1dee126431aafedabdabaa03ec2937 (diff) | |
download | markdown-86381a43fe13a7c87e8a0b07c6117f1767b6acc0.tar.gz markdown-86381a43fe13a7c87e8a0b07c6117f1767b6acc0.tar.bz2 markdown-86381a43fe13a7c87e8a0b07c6117f1767b6acc0.zip |
Merge pull request #185 from phihag/safemode-no-javascript-urls
Prevent javascript:// URLs
-rw-r--r-- | markdown/inlinepatterns.py | 3 | ||||
-rw-r--r-- | tests/safe_mode/link-targets.html | 2 | ||||
-rw-r--r-- | tests/safe_mode/link-targets.txt | 3 |
3 files changed, 8 insertions, 0 deletions
diff --git a/markdown/inlinepatterns.py b/markdown/inlinepatterns.py index a1b264c..1ebb310 100644 --- a/markdown/inlinepatterns.py +++ b/markdown/inlinepatterns.py @@ -364,6 +364,9 @@ class LinkPattern(Pattern): # Not a safe url return '' + if scheme == 'javascript': + return '' + # Url passes all tests. Return url as-is. return urlunparse(url) diff --git a/tests/safe_mode/link-targets.html b/tests/safe_mode/link-targets.html new file mode 100644 index 0000000..768ae5b --- /dev/null +++ b/tests/safe_mode/link-targets.html @@ -0,0 +1,2 @@ +<p><a href="">XSS</a> +See http://security.stackexchange.com/q/30330/1261 for details.</p>
\ No newline at end of file diff --git a/tests/safe_mode/link-targets.txt b/tests/safe_mode/link-targets.txt new file mode 100644 index 0000000..10eebda --- /dev/null +++ b/tests/safe_mode/link-targets.txt @@ -0,0 +1,3 @@ +[XSS](javascript://%0Aalert%28'XSS'%29;) +See http://security.stackexchange.com/q/30330/1261 for details. + |