mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
js regex rewrite: scheme-rel rewrite must be preceded by a quote no semicolon, to avoid rewriting ;//comment; as url
add rewrite tests
This commit is contained in:
parent
8eee469c93
commit
0f5d32e80e
@ -113,7 +113,7 @@ class JSLinkRewriterMixin(object):
|
|||||||
"""
|
"""
|
||||||
#JS_HTTPX = r'(?:(?:(?<=["\';])https?:)|(?<=["\']))\\{0,4}/\\{0,4}/[A-Za-z0-9:_@.-]+.*(?=["\s\';&\\])'
|
#JS_HTTPX = r'(?:(?:(?<=["\';])https?:)|(?<=["\']))\\{0,4}/\\{0,4}/[A-Za-z0-9:_@.-]+.*(?=["\s\';&\\])'
|
||||||
#JS_HTTPX = r'(?<=["\';])(?:https?:)?\\{0,4}/\\{0,4}/[A-Za-z0-9:_@.\-/\\?&#]+(?=["\';&\\])'
|
#JS_HTTPX = r'(?<=["\';])(?:https?:)?\\{0,4}/\\{0,4}/[A-Za-z0-9:_@.\-/\\?&#]+(?=["\';&\\])'
|
||||||
JS_HTTPX = r'(?<=["\';])(?:https?:)?\\{0,4}/\\{0,4}/[A-Za-z0-9:_@.-][^"\s\';&\\]*(?=["\';&\\])'
|
JS_HTTPX = r'(?:(?<=["\';])https?:|(?<=["\']))\\{0,4}/\\{0,4}/[A-Za-z0-9:_@.-][^"\s\';&\\]*(?=["\';&\\])'
|
||||||
|
|
||||||
def __init__(self, rewriter, rules=[]):
|
def __init__(self, rewriter, rules=[]):
|
||||||
rules = rules + [
|
rules = rules + [
|
||||||
|
@ -92,6 +92,9 @@ r"""
|
|||||||
>>> _test_js('cool_Location = "//example.com/abc.html" //comment')
|
>>> _test_js('cool_Location = "//example.com/abc.html" //comment')
|
||||||
'cool_Location = "/web/20131010/http://example.com/abc.html" //comment'
|
'cool_Location = "/web/20131010/http://example.com/abc.html" //comment'
|
||||||
|
|
||||||
|
>>> _test_js('A = B;//C + D;')
|
||||||
|
'A = B;//C + D;'
|
||||||
|
|
||||||
# document.cookie test
|
# document.cookie test
|
||||||
>>> _test_js('document.cookie = "a=b; Path=/"')
|
>>> _test_js('document.cookie = "a=b; Path=/"')
|
||||||
'document.WB_wombat_cookie = "a=b; Path=/"'
|
'document.WB_wombat_cookie = "a=b; Path=/"'
|
||||||
@ -103,6 +106,8 @@ r"""
|
|||||||
>>> _test_js('"http:\/\/sub-site.example.com\/path-dashes\/path_other\/foo_bar.txt"')
|
>>> _test_js('"http:\/\/sub-site.example.com\/path-dashes\/path_other\/foo_bar.txt"')
|
||||||
'"/web/20131010/http:\\/\\/sub-site.example.com\\/path-dashes\\/path_other\\/foo_bar.txt"'
|
'"/web/20131010/http:\\/\\/sub-site.example.com\\/path-dashes\\/path_other\\/foo_bar.txt"'
|
||||||
|
|
||||||
|
>>> _test_js('"a=b&http:\/\/example.com/;c=d"')
|
||||||
|
'"a=b&/web/20131010/http:\\/\\/example.com/;c=d"'
|
||||||
|
|
||||||
#=================================================================
|
#=================================================================
|
||||||
# XML Rewriting
|
# XML Rewriting
|
||||||
|
Loading…
x
Reference in New Issue
Block a user