firecat53 / urlscan

Mutt and terminal url selector (similar to urlview)
GNU General Public License v2.0
213 stars 37 forks source link

Strip CSS #57

Closed mgedmin closed 6 years ago

mgedmin commented 6 years ago

StackOverflow sends me emails that look like this:

(raw HTML) ``` Stack Overflow ... ```

urlscan displays them as this:

--------------------------------------------------------------------------------------------------------------------------------------------

.ExternalClass {width:100%;} .ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass
div {line-height: 130%;} #backgroundTable {margin:0; padding:0; width:100% !important; line-height: 100% !important;
background-color:#FFFFFF; font-family: Arial, Helvetica, sans-serif;} img {outline:none; text-decoration:none; -ms-interpolation-mode:
bicubic;} a img {border:none;} .image_fix {display:block;} p {margin: 1em 0;} p.footer { text-align: center; font-size: 12px; color:
#818386; } p.item-excerpt { color: #3d3d3d; margin-top: 5px; } p.item-link { margin: 5px 0 0 0; } span.item-label { color: #aaaaaa; } h1,
h2, h3, h4, h5, h6 { color: black; } h1 a, h2 a, h3 a, h4 a, h5 a, h6 a { color: blue; } h1 a:active, h2 a:active, h3 a:active, h4 a:active,
h5 a:active, h6 a:active { color: red ; } h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited { color: purple
; } table td {border-collapse: collapse;} table { border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt; } .emailfooter {
width: 600px; } .emailfooter td { padding-top: 30px; } a {color: #0077cc; text-decoration:none;} a:link { color: #0077cc; } a:visited {
color: #0077cc; } a:hover { color: #3da5ef; } #emailcontainer { width: 600px; border: 1px solid #eee; border-radius: 3px; background:
#ffffff; } @media only screen and (max-device-width: 480px), only screen and (max-width: 480px) { a[href^="tel"], a[href^="sms"] {
text-decoration: none; color: black; pointer-events: none; cursor: default; } .mobile_link a[href^="tel"], .mobile_link a[href^="sms"] {
text-decoration: default; color: orange !important; pointer-events: auto; cursor: default; } #emailcontainer { width: 90%; } .emailfooter {
width: 90%; } .header-text { font-size: 100%; line-height: 1.2; } .item-link { font-size: 100%; line-height: 22px; } .item-excerpt {
line-height: 18px; } } @media only screen and (min-device-width: 768px) and (max-device-width: 1024px), only screen and (min-width: 768px)
and (max-width: 1024px) { a[href^="tel"], a[href^="sms"] { text-decoration: none; color: blue; /* or whatever your want */ pointer-events:
none; cursor: default; } .mobile_link a[href^="tel"], .mobile_link a[href^="sms"] { text-decoration: default; color: orange !important;
pointer-events: auto; cursor: default; } #emailcontainer { width: 90%; } .emailfooter { width: 90%; } .header-text { font-size: 100%;
line-height: 1.2; } .item-link { font-size: 100%; line-height: 22px; } .item-excerpt { line-height: 18px; } }

You're almost done!
Click here to verify your new log in [3]
Questions? Comments? Let us know on our feedback site [4].

It would be nice if urlscan would not show me the text from <style> elements as it's not meant to be seen by humans.

firecat53 commented 6 years ago

Sorry for the delay...no time to look at this yet. Any chance you can either forward me the email or save it into a tar archive and send that ? That's the only way I can easily work on figuring it out. Once it ends up in a regular file format (like if I save the contents of this email or copy and paste to a file), most of the time I don't end up with the same results. Thanks!

Scott

mgedmin commented 6 years ago

It's a password reset email, and while I think the token should be expired by now, I don't feel comfortable sharing.

I'll see if I can find some other email that exhibits the same problem.

firecat53 commented 6 years ago

I'd really love to get ahold of an email exhibiting this behavior. I requested a password reset email from stackoverflow.com and I'm not seeing the same result that you did. Go figure! I've tried your patch against every test email I have, but I haven't seen any that show a different result. As I sure you can understand, I'm a little reluctant to merge the extra code unless I can see how it affects stuff. Is there any way you could edit the password recovery link just to change the personal info and still tar it up and send it to me?

Thanks!

He-Ro commented 6 years ago

If you still need a mail that exhibits this behaviour, then I uploaded a redacted mail here: https://ptpb.pw/IW49 You can add it to your test emails if you like.

With version 0.8.8 there is a lot of CSS in the beginning of the output. With version 0.8.9 it is gone and looks much better!

firecat53 commented 6 years ago

Perfect, thanks for the update!