When processing IMAP HTML emails, how can I quarantine in-line CSS? -


i'm building imap webmail client. problem html emails may include css affects layout / style of client.

the app front-end built on angularjs.

one potential solution use frames / iframes. problem these have provide src attribute. content reaching browser json data. potentially set back-end provide url each email means many more requests server.

looking @ gmail dom (for example) don't see use of frames, infer there must alternate techniques out there.

i worked on smallish project trying you're describing here, though different reasons. lot of hard work, , in end gave up, , went iframe solution.

the route tried similar spamassassin:

  1. we removed entire <head> extracting innerhtml of <body>.
  2. we removed embedded style tags using dom parser.
  3. we did regex (argh horror!) on matching <...float:left...> , munged replacing floatxxx:left. did every css property wanted 'quarantine'.

the problem that, while able 'quarantine' css, left of emails unusable. formatting-only css (such font-weight) got caught in crossfire, , never-ending list of regex patterns replace made horrendously slow.

we tried simplify putting lot of defaults @ top of page !important rules, munging inline !important rules. approach yahoo takes. improved performance continued make many emails unreadable.

i believe google's approach essential doing reverse polyfill - replace browser's way of, say, handling floats own. however, beyond our ability , didn't try it.

in end, iframe solution quick implement, , may quick enough satisfy users' needs. can roll out now, , update more complicated solution later. have added advantage pretty full css support. thing disable in iframed content javascript, can wreak havoc parent in way css cannot, , insecure.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -