concord-consortium / shutterbug

A rack utility using phantomjs that will create and save images (pngs) for a part of your web page's current dom. These images become available as public '.png' resources in the rack application. Currently shutterbug supports HTML, SVG and Canvas elements.
Other
27 stars 3 forks source link

Fixed quote encoding issue and removed unneeded XMLSerializer invocation [#98586586] #18

Closed dougmartin closed 9 years ago

dougmartin commented 9 years ago

Phantom's html entity decoder borks on single quotes when you have an encoded block with single quotes embedded in another encoded block with single quotes. The decoder will decode correctly up to the first single quote but then will leave the rest of the string encoded. If the single quotes are changed to double quotes then they are properly encoded within the enclosing block. For example:

" encodes to " which then encodes to &quote; when encoded within another block.

I was not able to run this code locally to verify the fix due to setup issues but when I did the following manually the grey screen shown in the PT bug was resolved:

  1. Decode each enclosing iframe data url src block until I got to the inner block
  2. Change the single quotes inserted by phantom_job.rb to double quotes and then re-encode the block and insert it back into the parent's iframe data url src param
  3. Repeat step 2 until I was back at the parent

I've also removed an unneeded use of XMLSerializer() that was a artifact of the initial dev work to fix the svg encoding issue.

knowuh commented 9 years ago

Looks good. :+1: