Menu

#1769 Base64 encoded data url is not decoded correctly

Latest SVN
closed
RBRi
None
1
2016-05-05
2016-04-07
Carsten
No

DataUrlDecoder.decodeUrl() will replace '+' with a space character before decoding the base64 resulting in an invalid byte[].

Real browsers do not do this see for example chromium:
https://code.google.com/p/chromium/codesearch#chromium/src/net/base/data_url.cc&sq=package:chromium&l=101

1 Attachments

Discussion

  • Ahmed Ashour

    Ahmed Ashour - 2016-04-07
    • status: open --> pending
     
  • Ahmed Ashour

    Ahmed Ashour - 2016-04-07

    Hi Carsten,

    I have difficulty making a test case against real browsers. DataURLDecoderTest was migrated to WebDriver.

    Can you post a case which works with real browsers but fail with HtmlUnit?

     
  • Carsten

    Carsten - 2016-04-28

    I found a way to test it but had some trouble asserting the correct behaviour with alerts because real browsers and HtmlUnit have different ouput. Also the input base64 and output base64 are not equal, not even in real browsers.

    Real firefox outputs a correct data url.
    Chrome and IE emulation output something which seems like an incomplete data url.
    Firefox emulation does throw an exception.

    My proposal for a fix is to copy URLCodec.decodeUrl(), remove the if that handles '+' and use that method in case the data url is base64 encoded.

     
  • Ahmed Ashour

    Ahmed Ashour - 2016-04-28
    • status: pending --> open
     
  • Ahmed Ashour

    Ahmed Ashour - 2016-04-28

    Thanks for feedback.

    DataURLDecoderTest.base64WithPlus was added as @NYI.
    Proposed change to DataURLDecoder2Test to be verified.

     
  • RBRi

    RBRi - 2016-05-05

    Did some detailed test on this and of course Carsten is right.
    Have added some more tests and implemented Carstens suggestion for the fix.
    Enjoy... :-)

    And as always: Carsten thanks for the report, the path and your ongoing support

     
  • RBRi

    RBRi - 2016-05-05
    • status: open --> closed
    • assigned_to: RBRi
     

Log in to post a comment.