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
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?
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.
Thanks for feedback.
DataURLDecoderTest.base64WithPlus was added as @NYI.
Proposed change to DataURLDecoder2Test to be verified.
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