diff --git a/README.asciidoc b/README.asciidoc index 7a1ef8bf2..0f28676ac 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -181,6 +181,7 @@ Contributors, sorted by the number of commits in descending order: * John ShaggyTwoDope Jenkins * Clayton Craft * Peter Vilim +* Maciej Wołczyk * knaggita * Oliver Caldwell * Julian Weigt @@ -188,7 +189,6 @@ Contributors, sorted by the number of commits in descending order: * Jonas Schürmann * error800 * Michael Hoang -* Maciej Wołczyk * Liam BEGUIN * Julie Engel * skinnay diff --git a/qutebrowser/browser/webkit/mhtml.py b/qutebrowser/browser/webkit/mhtml.py index 237898809..fbfeafef4 100644 --- a/qutebrowser/browser/webkit/mhtml.py +++ b/qutebrowser/browser/webkit/mhtml.py @@ -32,6 +32,7 @@ import email.generator import email.encoders import email.mime.multipart import email.message +import quopri from PyQt5.QtCore import QUrl @@ -138,6 +139,22 @@ def _check_rel(element): return any(rel in rels for rel in must_have) +def _encode_quopri_mhtml(msg): + """Encode the message's payload in quoted-printable. + + Substitute for quopri's default 'encode_quopri' method, which needlessly + encodes all spaces and tabs, instead of only those at the end on the + line. + + Args: + msg: Email message to quote. + """ + orig = msg.get_payload(decode=True) + encdata = quopri.encodestring(orig, quotetabs=False) + msg.set_payload(encdata) + msg['Content-Transfer-Encoding'] = 'quoted-printable' + + MHTMLPolicy = email.policy.default.clone(linesep='\r\n', max_line_length=0) @@ -146,7 +163,7 @@ E_BASE64 = email.encoders.encode_base64 # Encode the file using MIME quoted-printable encoding. -E_QUOPRI = email.encoders.encode_quopri +E_QUOPRI = _encode_quopri_mhtml class MHTMLWriter: diff --git a/tests/end2end/data/downloads/mhtml/complex/complex.mht b/tests/end2end/data/downloads/mhtml/complex/complex.mht index d7988cb63..f4cfb4649 100644 --- a/tests/end2end/data/downloads/mhtml/complex/complex.mht +++ b/tests/end2end/data/downloads/mhtml/complex/complex.mht @@ -8,143 +8,125 @@ Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
-=20=20=20=20=20=20=20=20 -=20=20=20=20=20=20=20=20This=20page=20is=20a=20test-case=20for=20the=20m= -html=20download=20feature=20of -=20=20=20=20=20=20=20=20qutebrowser.=20Under=20normal=20circumstances,=20yo= -u=20won't=20see=20this=20page,=20except -=20=20=20=20=20=20=20=20if=20you're=20a=20qutebrowser=20developer=20or<= -/em>=20you're=20attending=20one=20of -=20=20=20=20=20=20=20=20The-Compiler's=20pytest=20demos.
-=20=20=20=20=20=20=20=20 -=20=20=20=20=20=20=20=20This=20page=20references=20other=20assets=20and= -=20when=20the=20page=20is=20downloaded, -=20=20=20=20=20=20=20=20qutebrowser=20checks=20if=20each=20asset=20was=20do= -wnloaded.=20If=20some=20assets=20are -=20=20=20=20=20=20=20=20missing,=20the=20test=20fails=20and=20the=20poor=20= -developers=20have=20to=20search=20for=20the -=20=20=20=20=20=20=20=20error.
-=20=20=20=20=20=20=20=20 -=20=20=20=20=20=20=20=20Yes!
-=20=20=20=20=20=20=20=20 -=20=20=20=20=20=20=20=20See=20 -=20=20=20=20=20=20=20=20here=20for=20more=20information.
-=20=20=20=20=20=20=20=20 -=20=20=20=20=20=20=20=20To=20make=20this=20page=20a=20bit=20useful,=20I'= -ve=20included=20a=20chessboard,=20so=20you -=20=20=20=20=20=20=20=20can=20play=20chess.=20Just=20turn=20your=20screen= -=2090=20degrees,=20such=20that=20it=20forms=20a -=20=20=20=20=20=20=20=20flat,=20horizontal=20surface=20(you=20can=20skip=20= -this=20step=20if=20you're=20using=20a -=20=20=20=20=20=20=20=20tablet).=20Next,=20zoom=20the=20page=20until=20it= -=20fits=20your=20needs.=20Enjoy=20your=20round -=20=20=20=20=20=20=20=20of=20chess!
-=20=20=20=20=20=20=20=20 -=20=20=20=20=20=20=20=20 -=20=20=20=20 + +This page is a test-case for the mhtml download feature of + qutebrowser. Under normal circumstances, you won't see this page, e= +xcept + if you're a qutebrowser developer or you're attending one = +of + The-Compiler's pytest demos.
+ =20 +This page references other assets and when the page is downloade= +d, + qutebrowser checks if each asset was downloaded. If some assets are + missing, the test fails and the poor developers have to search for = +the + error.
+ =20 +Yes!
+ =20 +See + here for more information.
+ =20 +#qutebrowser
on
+ irc.freenode.net
+ To make this page a bit useful, I've included a chessboard, so y= +ou + can play chess. Just turn your screen 90 degrees, such that it form= +s a + flat, horizontal surface (you can skip this step if you're using a + tablet). Next, zoom the page until it fits your needs. Enjoy your r= +ound + of chess!
+ + + =20 -----=_qute-5314618b-e51d-46e1-9598-103536e86b59 @@ -709,35 +691,33 @@ MIME-Version: 1.0 Content-Type: text/css; charset=utf-8 Content-Transfer-Encoding: quoted-printable -@import=20'external-in-extern.css'; -/*=20We=20want=20to=20make=20sure=20that=20assets=20referenced=20in=20exter= -nal=20css=20files=20are -=20*=20properly=20included -=20*/ -div.dyk=20{ -=20=20=20=20/*=20Did=20you=20know?=20*/ -=20=20=20=20background-image:=20url('DYK.png'); -=20=20=20=20background-repeat:=20no-repeat; -=20=20=20=20/*=20Image=20is=20128px=20wide=20*/ -=20=20=20=20min-height:=20128px; -=20=20=20=20padding-left:=20148px; -=20=20=20=20margin-top:=2010px; -=20=20=20=20margin-bottom:=2010px; -=20=20=20=20border:=202px=20solid=20#474747; -=20=20=20=20border-radius:=2064px; +@import 'external-in-extern.css'; +/* We want to make sure that assets referenced in external css files are + * properly included + */ +div.dyk { + /* Did you know? */ + background-image: url('DYK.png'); + background-repeat: no-repeat; + /* Image is 128px wide */ + min-height: 128px; + padding-left: 148px; + margin-top: 10px; + margin-bottom: 10px; + border: 2px solid #474747; + border-radius: 64px; } -=20=20=20=20 + =20 -----=_qute-5314618b-e51d-46e1-9598-103536e86b59 Content-Location: http://localhost:1337/data/downloads/mhtml/complex/external-in-extern.css MIME-Version: 1.0 Content-Type: text/css; charset=utf-8 Content-Transfer-Encoding: quoted-printable -/*=20Just=20making=20sure=20that=20more=20than=20one=20level=20of=20externa= -l=20css=20is=20included=20*/ -h1,=20h2,=20h3,=20h4,=20h5,=20h6=20{ -=20=20=20=20color:=20#0A396E; -=20=20=20=20border-bottom:=201px=20dotted=20#474747; +/* Just making sure that more than one level of external css is included */ +h1, h2, h3, h4, h5, h6 { + color: #0A396E; + border-bottom: 1px dotted #474747; } -----=_qute-5314618b-e51d-46e1-9598-103536e86b59 Content-Location: http://localhost:1337/data/downloads/mhtml/complex/favicon.png diff --git a/tests/end2end/data/downloads/mhtml/simple/simple.mht b/tests/end2end/data/downloads/mhtml/simple/simple.mht index d0b7a7c48..ef4431362 100644 --- a/tests/end2end/data/downloads/mhtml/simple/simple.mht +++ b/tests/end2end/data/downloads/mhtml/simple/simple.mht @@ -7,14 +7,13 @@ MIME-Version: 1.0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable - -=20=20=20=20=20=20=20=20 -=20=20=20=20=20=20=20=20