You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by GitBox <gi...@apache.org> on 2021/01/26 16:00:51 UTC
[GitHub] [incubator-daffodil] mbeckerle commented on a change in pull request #481: ADD test for "%%" to bypass existing test for "%NL"
mbeckerle commented on a change in pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#discussion_r564627761
##########
File path: daffodil-lib/src/main/scala/org/apache/daffodil/cookers/EntityReplacer.scala
##########
@@ -568,7 +568,9 @@ trait NoCharClassEntitiesMixin {
* Override if set of prohibited class entities is different
*/
protected def noCharClassEntities(raw: String, context: ThrowsSDE): Unit = {
- context.schemaDefinitionUnless(!raw.contains("%NL;"), "Property dfdl:%s cannot contain %%NL;", propName)
+ if(!raw.contains("%%")){
+ context.schemaDefinitionUnless(!raw.contains("%NL;"), "Property dfdl:%s cannot contain %%NL;", propName)
+ }
Review comment:
I think you want to modify NoCharClassEntitiesMixin to make the checks do more than just search for %NL; or similar, because that does not exclude "%%NL;" which is allowed.
The correct predicate test really has to use a regex to find an "unescaped %". The regex for this is quite tricky. It has to prevent an odd number of consecutive % characters. E.g., "%%%NL;" is %% then %NL;, so should cause an SDE. But "%%%%" is %%, %%, NL; which is allowed. A regex for "unescaped %" is the key concept, and this odd/even number of % is the core idea, and that can definitely be done with a regex.
BTW: my regex goto links are:
http://myregextester.com/
http://rick.measham.id.au/paste/explain.pl
https://www.regular-expressions.info/lookaround.html
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org