mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
Updated RewriteInfo._resolve_text_type to recognize the fr_
rewrite modifier (indicates that the content is from a frameset's frame) (#438)
Added a test, test_rewrite_frameset_frame_content, to test_content_rewriter.py for these changes
This commit is contained in:
parent
529a587cdc
commit
777cc30e82
@ -434,7 +434,7 @@ class RewriteInfo(object):
|
|||||||
# if html or no-content type, allow resolving on js, css,
|
# if html or no-content type, allow resolving on js, css,
|
||||||
# or other templates
|
# or other templates
|
||||||
if text_type in ('guess-text', 'guess-html'):
|
if text_type in ('guess-text', 'guess-html'):
|
||||||
if not is_js_or_css and mod not in ('if_', 'mp_', 'bn_', ''):
|
if not is_js_or_css and mod not in ('fr_', 'if_', 'mp_', 'bn_', ''):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# if application/octet-stream binary, only resolve if in js/css content
|
# if application/octet-stream binary, only resolve if in js/css content
|
||||||
|
@ -524,6 +524,24 @@ class TestContentRewriter(object):
|
|||||||
|
|
||||||
assert b''.join(gen).decode('utf-8') == '{"ssid":"5678"}'
|
assert b''.join(gen).decode('utf-8') == '{"ssid":"5678"}'
|
||||||
|
|
||||||
|
def test_rewrite_frameset_frame_content(self):
|
||||||
|
"""Determines if the content rewriter correctly determines that HTML loaded via a frameset's frame,
|
||||||
|
frame's src url is rewritten with the **fr_** rewrite modifier, is content to be rewritten
|
||||||
|
"""
|
||||||
|
headers = {'Content-Type': 'text/html; charset=UTF-8'}
|
||||||
|
prefix = 'http://localhost:8080/live/'
|
||||||
|
dt = '20190205180554%s'
|
||||||
|
content = '<!DOCTYPE html><head><link rel="icon" href="http://r-u-ins.tumblr.com/img/favicon/72.png" ' \
|
||||||
|
'type="image/x-icon"></head>'
|
||||||
|
rw_headers, gen, is_rw = self.rewrite_record(headers, content, ts=dt % 'fr_',
|
||||||
|
prefix=prefix,
|
||||||
|
url='http://r-u-ins.tumblr.com/',
|
||||||
|
is_live='1')
|
||||||
|
# is_rw should be true indicating the content was rewritten
|
||||||
|
assert is_rw
|
||||||
|
assert b''.join(gen).decode('utf-8') == content.replace('href="', 'href="%s%s' % (prefix, dt % 'oe_/'))
|
||||||
|
assert rw_headers.headers == [('Content-Type', 'text/html; charset=UTF-8')]
|
||||||
|
|
||||||
def test_custom_live_only(self):
|
def test_custom_live_only(self):
|
||||||
headers = {'Content-Type': 'application/json'}
|
headers = {'Content-Type': 'application/json'}
|
||||||
content = '{"foo":"bar", "dash": {"on": "true"}, "some": ["list"]'
|
content = '{"foo":"bar", "dash": {"on": "true"}, "some": ["list"]'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user