You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by "PJ Fanning (Jira)" <ji...@apache.org> on 2022/02/10 13:21:00 UTC

[jira] [Commented] (XMLBEANS-599) Line breaks in base64binary cause a validation error

    [ https://issues.apache.org/jira/browse/XMLBEANS-599?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17490210#comment-17490210 ] 

PJ Fanning commented on XMLBEANS-599:
-------------------------------------

sounds like a reasonable change - any interest in doing a PR yourself? - the committer base on this project is pretty small

> Line breaks in base64binary cause a validation error
> ----------------------------------------------------
>
>                 Key: XMLBEANS-599
>                 URL: https://issues.apache.org/jira/browse/XMLBEANS-599
>             Project: XMLBeans
>          Issue Type: Bug
>    Affects Versions: Version 5.0.3
>            Reporter: Daniel Hengst
>            Priority: Major
>
> When trying to migrate from XmlBeans 3.1.0 to 5.0.3 the following issue caused some unit tests to fail:
>  
> The XML data contains elements of type base64binary which have line breaks.
> Validation via XmlObject.validate() now returns an error:
> "error: base64Binary: Invalid value: not encoded properly".
> The error originates from the class org.apache.xmlbeans.impl.values.JavaBase64Holder:
> {code:java}
>     public static byte[] lex(String v, ValidationContext c) {
>         try {
>             return Base64.getDecoder().decode(v);
>         } catch (IllegalArgumentException var3) {
>             c.invalid("base64Binary", new Object[]{"not encoded properly"});
>             return null;
>         }
>     }
> {code}
> The decode call fails with an IllegalArgumentException "Illegal base64 character 20".
> (It's character 20 because XmlBeans converts the line break to a space in XmlWhitespace.collapse().)
> The definition of the base64binary type allows for the presence of whitespace
> [https://www.w3.org/TR/xmlschema-2/#base64Binary]
> Therefore I'd suggest to change the Base64 call as follows:
> {code:java}
> Base64.getMimeDecoder().decode(v);
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org