File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
src/zimscraperlib/rewriting Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -602,7 +602,11 @@ def rewrite_href_src_attributes(
602602 This is also notifying of any JS script found used as a module, so that this script
603603 is properly rewritten when encountered later on.
604604 """
605- if attr_name not in ("href" , "src" ) or not attr_value :
605+ if (
606+ attr_name not in ("href" , "src" )
607+ or not attr_value
608+ or attr_value .startswith ("data:" )
609+ ):
606610 return
607611 if (
608612 notify_js_module
Original file line number Diff line number Diff line change 6868 ContentForTests (input_ = "<!DOCTYPE html>A simple string with doctype" ),
6969 ContentForTests (input_ = "A simple string with <!-- cc --> comment" ),
7070 ContentForTests (input_ = "A simple string with <?xml ?> pi" ),
71+ ContentForTests (
72+ input_ = '<script type="module" '
73+ 'src="data:application/javascript;base64,QQQQ"></script>'
74+ ),
7175 ]
7276)
7377def no_rewrite_content (request : pytest .FixtureRequest ):
7478 yield request .param
7579
7680
7781def test_no_rewrite (no_rewrite_content : ContentForTests ):
82+
83+ def noop_notify (zim_path : ZimPath ):
84+ pass
85+
7886 assert (
7987 HtmlRewriter (
80- ArticleUrlRewriter (
88+ url_rewriter = ArticleUrlRewriter (
8189 article_url = HttpUrl (f"http://{ no_rewrite_content .article_url } " ),
8290 ),
83- None ,
84- None ,
85- None ,
91+ pre_head_insert = None ,
92+ post_head_insert = None ,
93+ notify_js_module = noop_notify ,
8694 )
8795 .rewrite (no_rewrite_content .input_str )
8896 .content
You can’t perform that action at this time.
0 commit comments