You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by "Mike Beckerle (Jira)" <ji...@apache.org> on 2021/03/10 21:55:00 UTC

[jira] [Commented] (DAFFODIL-2479) Using %#x25; character class causes invariant abort

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

Mike Beckerle commented on DAFFODIL-2479:
-----------------------------------------

The right behavior here is for all the "%" special processing to happen at once, and it's not "re-applied" or done in passes. 

So "%#x25;" gets turned into a single "%" in the same way that "%%" gets turned into a single "%"

The other alternative design point leads to absurd things like this:

"%#x25;#x25;#x25;#x25;#x25;#x25;#x25;#x25;#x25;#x25;#x25;" being also just a single "%". Clearly wrong. 

That means the check for single % at the end of the string has to happen before any DFDL entities are converted including numeric entities. 

(Note that XML Entities, like "&#x25;" are always gone by the time we see the string at the earliest point, so ending a string with "&#x25;" is exactly like ending it with "%", and "%&#x25;" is exactly equivalent to "%%". )

 

> Using %#x25; character class causes invariant abort
> ---------------------------------------------------
>
>                 Key: DAFFODIL-2479
>                 URL: https://issues.apache.org/jira/browse/DAFFODIL-2479
>             Project: Daffodil
>          Issue Type: Bug
>          Components: Front End
>    Affects Versions: 3.0.0
>            Reporter: Steve Lawrence
>            Priority: Major
>
> I have a file format where it is natural to specify initiators using hex character classes because the specification uses hex values. One case of this is an initator that has a value of 0x25 in hex. In ASCII encoding this is the percent character (%). For example:
> {code:xml}
> <xs:element name="foo" type="xs:string" dfdl:initiator="%#x25;" />
> {code}
> Using the above leads to the following invariant abort:
> {code:none}
> org.apache.daffodil.exceptions.Abort: Invariant broken. delimStr should not end in an isolated single %. DelimStr = %
> org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
> org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
> org.apache.daffodil.processors.Delimiter.buildDelimBuf(DFDLDelimiter.scala:331)
> org.apache.daffodil.processors.Delimiter.compileDelimiter(DFDLDelimiter.scala:69)
> 	at org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
> 	at org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
> 	at org.apache.daffodil.processors.Delimiter.buildDelimBuf(DFDLDelimiter.scala:331)
> 	at org.apache.daffodil.processors.Delimiter.compileDelimiter(DFDLDelimiter.scala:69)
> 	at org.apache.daffodil.processors.dfa.CreateDelimiterDFA$.apply(CreateDelimiterDFA.scala:68)
> 	at org.apache.daffodil.processors.dfa.CreateDelimiterDFA$.$anonfun$apply$3(CreateDelimiterDFA.scala:97)
> {code}
> It looks like Daffodil is treating this exactly as if it were a "%". For example, if I change the initiator to this:
> {code:xml}
> <xs:element name="foo" type="xs:string" dfdl:initiator="%#x25;NL;" />
> {code}
> then it looks for a newline initator (i.e. %NL\;)
> Note that {{dfdl:initiator="%"}} does give a helpful error message, so this is specific to using a character class entity that encodes to a percent.
> The workaround is to specify the initiator as "%%" (i.e. an escaped percent). This works fine, but is not ideal in this case because all initiators are better described using hex values.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)