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/25 17:53:17 UTC

[GitHub] [incubator-daffodil] regetom opened a new pull request #481: ADD test for "%%" to bypass existing test for "%NL"

regetom opened a new pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481


   Add an if test to the noCharClassEntities function to not throw an SDE when the passed string
   contains "%%NL"
   
   daffodil-774


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] mbeckerle commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
mbeckerle commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-768467142


   I think you need to call findAllMatchIn, not findAllIn. I think findAllIn has to be used with an iterator pattern because there is just one Match object that is being advanced. Whereas findAllMatchIn provides separate match objects with disjoint state. 


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-771707971






----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] stevedlawrence commented on a change in pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on a change in pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#discussion_r564646521



##########
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:
       Ah yeah, that's much simpler than what I was thinking. A even/odd check should do it just fine. 




----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-768544391


   There are a couple of places in EntityReplacer.scala where the noCharClassEntities() is overridden in another class.  The class StringLiteralESEntityWithByteEntities() has the same original functions calls except for 'ES'.  The class ListOfStringLiteralNoCharClass_NL_ES_EntitiedsNoByteEntities() also overrides the function but only has function calls for "NL' and "ES".  The classes NonEmptyListOfStringLiteralCharClass_ES_WithByteEntities() and DelimiterCookerNoES() also override the functions.  Should all of these be modified to follow the new logic?


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] mbeckerle commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
mbeckerle commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-768561649


   Title of this PR no longer matches the nature of the change. This is "a good thing (tm)".
   
    Probably name of the corresponding JIRA ticket too. Suggest change to "Improve detection of disallowed entities in property values" or something like that. 


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] stevedlawrence commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-768413213


   I'd actually prefer to see a more human description, for example the description I gave above
   
   > So first we look for either the beginning of the string or a non-% character with (^|[^%]). Following that, we look for an even number of %'s with (%%)*. And finally following that we look for a %NL;. I think that should match any %NL; not immediately preceeded by an even number of %'s, in other words, an unescaped %NL;.
   
   This could definitely use improvment, but I think it's more clear what the regex is actually testing, and can give additional information about why we are looking for things (e.g. we need even number of %'s). If that explanation isn't clear, someone can always copy/paste the regex into a regex explainer tool and get a symbol by symbol breakdown.
   
   Also, there might be some potential licensing issues? Not sure if those explains have a license for that output (or if it's even licensable). But always somethign to consider when copy/pasting something off the web. 


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] stevedlawrence commented on a change in pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on a change in pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#discussion_r564588926



##########
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:
       This is actually a really tricky and subtle situtation. Because of this, I think this isn't quite right for the check to fix DAFFODIL-774.
   
   As an example, textStandardZeroRep property is not allowed to contain the NL and ES character classes. So something like this is not allowed:
   ```xml
   <xs:element ... dfdl:textStandardZeroRep="0_%NL;" />
   ```
   In this example we have a zero rep of the string ``0``, followed by an underscore, followed by a newline. I believe this works as intented right now and creates an SDE because this contains an unallowed ``%NL;``
   
   However, someone could theoretically do something like this (note the escaping `%%`` before NL):
   ```xml
   <xs:element ... dfdl:textStandardZeroRep="0_%%NL;" />
   ```
   So the zero rep in this case is the string ``0``, followed by an underscore, followed by the literal string ``%NL;`` instead of a newline. We would currently consider that an SDE because the raw string contains ``%NL;``, even though that's not really a ``%NL;`` because the ``%`` is escaped via a double ``%``. Note that it is very unlikely for a user to ever want a literal ``%NL;`` as a property value, so one might even argue making this check better as DAFFODIL-744 describes isn't worth it. Though it is an interesting excercise, and would make Daffodil more correct if we did add it.
   
   However, what your check would do is make it so that if the raw property value contains ``%%`` then we don't even bother checking for ``%NL;`` at all. So for example, say we had something like this:
   ```xml
   <xs:element ... dfdl:textStandardZeroRep="0%%_%NL;" />
   ```
   So in this case, the user specified that the zero rep is the string ``0``, followed by a single perect sign (%% escape means single perect), followed by an underscore, followed by a newline. This shouldn't be allowed because the zero rep contains ``%NL;``. But because it contains %%, your new check would skip the ``%NL;`` check and it won't error as it should. Again, this is a contrived example, but that's what this edge case is talking about.
   
   To properly fixed DAFFODIL-744, I don't think it's enough to just do simple string searches on the raw value like we do now. How we detect %NL; and other disallowed character classes must change, because it's too difficult to take into account all the different escape combinations. I think instead of looking at the raw value, we need to inspect the cooked value (or what we do with the cooked value). I'm not too familar with that code, but I think cooking the strings is supposed to deal with things like escaped percents, character classes, etc. and so the cooked result should have that escaping done and provide information to actually know if the property actually contains an unescaped %NL; or not. I'm not positive about this though.
   
   If it's not clear where to get starting on making that change, it might be helpful to start a discussion on the dev list and see if there are any other ideas on how to best fix this, or maybe we'll decide it's not even worth the effort. It is a very rare edge case.
   
   Whatever the solution, we also must make sure it works for ES, WSP, WSP+ and other character classes. Although the bug only lists NL as a problem, this same escaping issue exists for those properties.
   
   Also, if you do continue working on this, I would reccommend starting with writing some TDML tests (maybe using the examples I've mentioned above as a starting point) to show we have the incorrect behavior, and what the correct behavior should be for some more complex cases with lots of escaping going on. It we determine the fix isn't worth the effort, we would at least have tests showing the expected behavior and how Daffodil doesn't do the right thing in case we ever do decide to fix it. 




----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] mbeckerle commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
mbeckerle commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-771714932


   If the code is self explanatory, because the lists of allowed/disallowed entities are explicitly sitting there, then yeah, no comments are needed. Given a list of them though, it may not be obvious which one is not there. So a comment like // Not ES
   may be helpful.
   Alternatively you can do something like:
   ```
   val entitiesWithoutES = Seq("%NL;", ....)
   ```
   To make it self-documenting without using comments.
   
   But in general, push your changes and let's see how it is coming out. 
   I often push changes and immediately put some comments on the PR myself to ask people what they think about this or that aspect. Just like your question here. 


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-771707971


   The overriden examples of noCharClassEntities((), have comments like:
     /**
      * Override Because ES is allowed.
      */
   I am replacing the override functions with calls to the new function.  I am thinking I should modify these comments, but I am not sure what to say.  Something like?
   */
    * Disallow %NL, %WSP, %WSP+, WSP* character class entities
    * /
    Or should I just remove the comments altogether?
   


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom edited a comment on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom edited a comment on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-773963265


   I took at look at why all the checks failed.  Unit tests are expecting results back like:
   "cannot contain %ES;"
   With the modifications, the wording for the new results has changed and the entities are combined:
   Property dfdl:test contains disallowed character classes: %NL;, %ES;
   I tried to determine where the unit tests are in the code base, but the paths in the failed check details don't seem to match the paths in the code base.


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] stevedlawrence commented on a change in pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on a change in pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#discussion_r570984136



##########
File path: daffodil-lib/src/main/scala/org/apache/daffodil/cookers/EntityReplacer.scala
##########
@@ -560,48 +560,67 @@ sealed trait SingleCharacterMixin { self: StringLiteralBase =>
 class SingleCharacterLiteral(pn: String, allowByteEntities: Boolean)
   extends StringLiteralBase(pn, allowByteEntities) with SingleCharacterMixin
 
-trait NoCharClassEntitiesMixin {
+trait DisallowedCharClassEntitiesMixin {
 
   protected def propName: String
+  protected def disallowedCharClassEntities: Seq[String]
 
   /**
-   * Override if set of prohibited class entities is different
+   * The raw string to test is supplied as the first parameter
+   * A list of disallowed character class entities is supplied as the 2nd parameter
+   * This list is added to the regex string below
+   * Ex regex: (?:^|[^%])(?:%%)*(%(?:NL|ES);)
+   * (?:^|[^%]) look for the beginning of the string or a non-% character
+   * (?:%%)* look for an even number of %'s
+   * (%(?:NL|ES);) look for any single % left after previous match along with and NL or ES followed by a ;
+   *
    */
-  protected def noCharClassEntities(raw: String, context: ThrowsSDE): Unit = {
-    context.schemaDefinitionUnless(!raw.contains("%NL;"), "Property dfdl:%s cannot contain %%NL;", propName)
-    context.schemaDefinitionUnless(!raw.contains("%ES;"), "Property dfdl:%s cannot contain %%ES;", propName)
-    context.schemaDefinitionUnless(!raw.contains("%WSP;"), "Property dfdl:%s cannot contain %%WSP;", propName)
-    context.schemaDefinitionUnless(!raw.contains("%WSP+;"), "Property dfdl:%s cannot contain %%WSP+;", propName)
-    context.schemaDefinitionUnless(!raw.contains("%WSP*;"), "Property dfdl:%s cannot contain %%WSP*;", propName)
+  private lazy val disallowedRegex = {
+    val disallowedCharClassMatch = disallowedCharClassEntities.mkString("|")
+    val regexString = "(?:^|[^%])(?:%%)*(%(?:" + disallowedCharClassMatch + ");)"
+    regexString.r
   }
 
   protected def testRaw(raw: String, context: ThrowsSDE): Unit = {
-    noCharClassEntities(raw, context)
+    val matchedGroups = disallowedRegex.findAllMatchIn(raw).map {_.group(1)}
+    context.schemaDefinitionUnless(
+      matchedGroups.isEmpty,
+      "Property dfdl:%s contains disallowed character classes: %s" ,
+      propName,
+      matchedGroups.mkString(", "))
   }
 }
 
 class StringLiteralNoCharClassEntities(pn: String, allowByteEntities: Boolean)
   extends StringLiteralBase(pn, allowByteEntities)
-  with NoCharClassEntitiesMixin {
+  with DisallowedCharClassEntitiesMixin {
 
+  // Check for all NL|ES|WSP|WSP+|WSP*
+  override val disallowedCharClassEntities = Seq("NL", "ES", "WSP", "WSP+", "WSP*")

Review comment:
       I'm guessing the cause of some of the errors you're seeing (e.g. WSP not allowed in the dfdl:separator property) is that ``WSP+`` and ``WSP*`` contain regex characters. So if we blindly throw those in a regex, it will mess with our matches. We want to match the literal string ``WSP+``, but treating that as a regex will match ``WS`` followed by one or more ``P``'s, which we definitely don't want. Smilar issues for ``WSP*``.
   
   Fortunately, it looks like the ``java.util.regex.Pattern`` class has a function just for escaping literal strings that are inserted into regex's. So I think we can just change the above to something like this, so that we escape all the disallowed char class entities before putting them in the regex.
   ```scala
   val disallowedCharClassMatch = disallowedCharClassEntities.map(Pattern.quote).mkString("|")
   ```
   Hopefully that will get rid of some of the errors.




----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-768527948


   I thought it was there so the SDE prints properly.  
   context.schemaDefinitionUnless(!raw.contans("%NL;"), "Property dfdl:%s cannot contain %%NL;", propName)
   It was in the string passed to schemDefinitionUnless in the current code.
   


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] stevedlawrence commented on a change in pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on a change in pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#discussion_r570984136



##########
File path: daffodil-lib/src/main/scala/org/apache/daffodil/cookers/EntityReplacer.scala
##########
@@ -560,48 +560,67 @@ sealed trait SingleCharacterMixin { self: StringLiteralBase =>
 class SingleCharacterLiteral(pn: String, allowByteEntities: Boolean)
   extends StringLiteralBase(pn, allowByteEntities) with SingleCharacterMixin
 
-trait NoCharClassEntitiesMixin {
+trait DisallowedCharClassEntitiesMixin {
 
   protected def propName: String
+  protected def disallowedCharClassEntities: Seq[String]
 
   /**
-   * Override if set of prohibited class entities is different
+   * The raw string to test is supplied as the first parameter
+   * A list of disallowed character class entities is supplied as the 2nd parameter
+   * This list is added to the regex string below
+   * Ex regex: (?:^|[^%])(?:%%)*(%(?:NL|ES);)
+   * (?:^|[^%]) look for the beginning of the string or a non-% character
+   * (?:%%)* look for an even number of %'s
+   * (%(?:NL|ES);) look for any single % left after previous match along with and NL or ES followed by a ;
+   *
    */
-  protected def noCharClassEntities(raw: String, context: ThrowsSDE): Unit = {
-    context.schemaDefinitionUnless(!raw.contains("%NL;"), "Property dfdl:%s cannot contain %%NL;", propName)
-    context.schemaDefinitionUnless(!raw.contains("%ES;"), "Property dfdl:%s cannot contain %%ES;", propName)
-    context.schemaDefinitionUnless(!raw.contains("%WSP;"), "Property dfdl:%s cannot contain %%WSP;", propName)
-    context.schemaDefinitionUnless(!raw.contains("%WSP+;"), "Property dfdl:%s cannot contain %%WSP+;", propName)
-    context.schemaDefinitionUnless(!raw.contains("%WSP*;"), "Property dfdl:%s cannot contain %%WSP*;", propName)
+  private lazy val disallowedRegex = {
+    val disallowedCharClassMatch = disallowedCharClassEntities.mkString("|")
+    val regexString = "(?:^|[^%])(?:%%)*(%(?:" + disallowedCharClassMatch + ");)"
+    regexString.r
   }
 
   protected def testRaw(raw: String, context: ThrowsSDE): Unit = {
-    noCharClassEntities(raw, context)
+    val matchedGroups = disallowedRegex.findAllMatchIn(raw).map {_.group(1)}
+    context.schemaDefinitionUnless(
+      matchedGroups.isEmpty,
+      "Property dfdl:%s contains disallowed character classes: %s" ,
+      propName,
+      matchedGroups.mkString(", "))
   }
 }
 
 class StringLiteralNoCharClassEntities(pn: String, allowByteEntities: Boolean)
   extends StringLiteralBase(pn, allowByteEntities)
-  with NoCharClassEntitiesMixin {
+  with DisallowedCharClassEntitiesMixin {
 
+  // Check for all NL|ES|WSP|WSP+|WSP*
+  override val disallowedCharClassEntities = Seq("NL", "ES", "WSP", "WSP+", "WSP*")

Review comment:
       I'm guessing the cause of some of the errors you're seeing (e.g. WSP not allowed in the dfdl:separator property) is that ``WSP+`` and ``WSP*`` contain regex characters. So if we blindly throw those in a regex, it will mess with our matches. We want to match the literal string ``WSP+``, but treating that as a regex will match ``WS`` followed by one or more ``P``'s, which we definitely don't want. Smilar issues for ``WSP*``.
   
   Fortunately, it looks like the ``java.util.regex.Pattern`` class has a function just for escaping literal strings that are inserted into regex's. So I think we can just change the above to something like this, so that we escape all the disallowed char class entities before putting them in the regex.
   val disallowedCharClassMatch = disallowedCharClassEntities.map(Pattern.quote).mkString("|")
   ```
   Hopefully that will get rid of some of the errors.




----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] stevedlawrence commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-768384545


   @regetom yep, I think something like that is the right approach. Note that with Mike's technique of finding all illegal character classes in a single regex, I think we could use ``findAllIn`` instead of just finding the first with ``findFirstIn``. That way we can gather all the capture groups and output an error that includes all of them rather than just erroring on the first one found, maybe something like this (untested):
   
   ```scala
   val matchedGroups = regex.findAllIn(raw).map { _.group(1) }
   schemaDefinitionUnless(
     matchedGroups.isEmpty,
     "Property dfdl:%s contains disallowed character classes: %s",
     propName,
     matchedGroups.mkString(", "))
   ```


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-768386004


   when  I use (?:^|[^%])(?:%%)*(%(?:NL|ES)\;) I get this:
   ![image](https://user-images.githubusercontent.com/11149210/106017335-599cc180-608e-11eb-9f64-39574bfc474f.png)
   This works though ("(?:^|[^%])(?:%%)*(%(?:NL|ES))
   ![image](https://user-images.githubusercontent.com/11149210/106017634-a7b1c500-608e-11eb-8d09-2701197306e0.png)
   
   


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] stevedlawrence commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-768533939


   Yep, in that case you do need to escape the % because the second paramater of schemaDefinitionUnless is a format string. But when you this:
   ```scala
   schemaDefinitionUnless(..., "Property dfdl:%s contains disallowed character classes: %s", propName, matchedGroups.mkString(", "))
   ```
   The format string only contains ``%s``, it doesn't contain ``%NL;`` anymore. The result of ``matchedGroups.mkString(", ")`` is just one giant string that does happen to contain %'s, but they aren't anything special because they aren't in the format string. schemaDefinitionUnless does a strait replace of %s with that string, and ignores the fact that the string might have perects in it.


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] stevedlawrence commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-768550106


   Definitely agreed. We should definitely try to factor out as much duplication as possible into a single function. Maybe something like each of these cookers that have invalid entities must implement a variable that's says what's disallows, e.g.
   ```scala
   val disallowedCharClassEntities = Seq("NL", "ES", ...)
   ```
   This can then be used to build the appropriate regex that the noCharClassEntities() would then use. No need to override that function anymore, and hides the complex regex so you don't have to dicipher it just to change/verify which entities are allowed.


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-771946138


   I added the parameter disallowedCharClassEntities: String to noCharClassEntities().  I was able to eliminate all the overrides of noCharClassEntities except for class DelimiterCookerNoES.  The error string built there also include this phrase'when dfdl:lengthKind=\"delimited\"."'.  This is the only class that includes extra text in the error string.  I was thinking about adding an additional parameter extraText: String to the noCharClassEntities() funtion, but I wasn't sure if that was the best solution.  I getting an error compiling this class because the override no longer matches the parameters in the noCharClassEntities() funtion.   Once I have a solution for that I will check the code in.


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-767492246


   Not sure why the Run Rat Check ran 5 hours 48 minutes and 49 seconds and had to be canceled for Java15, Scala2.12.11, Windows-latest test. All other Run RAT Check tests completed in less than 34 seconds.


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom commented on a change in pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom commented on a change in pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#discussion_r568950951



##########
File path: daffodil-lib/src/main/scala/org/apache/daffodil/cookers/EntityReplacer.scala
##########
@@ -810,7 +809,7 @@ class DelimiterCookerNoES(pn: String) extends ListOfString1OrMoreLiteral(pn, tru
   override val oneLiteralCooker: StringLiteralBase =
     new StringLiteralNoCharClassEntities(propName, true) {
 
-      override protected def noCharClassEntities(raw: String, context: ThrowsSDE): Unit = {
+      override protected def noCharClassEntities(raw: String, disallowedCharClassEntities: String, context: ThrowsSDE): Unit = {
         // TODO: this isn't quite right, as it will allow combined delimiters

Review comment:
       I added the parameter disallowedCharClassEntities here to match the def above, but I am not using the function because of the additional error message test for these items. Perhaps there is a better way to handle this?




----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] stevedlawrence commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-774038638


   > I took a look at why all the checks failed. Unit tests are expecting results back like:
   > "cannot contain %ES;"
   > With the modifications, the wording for the new results has changed and the entities are combined:
   > Property dfdl:test contains disallowed character classes: %NL;, %ES;
   
   I think this is very likely part of the issue. We probably just need to update the TDML files for these negative tests to check for different keywords in the error message.
   
   Though, I think we may need to double check which entities are disallowed. For example, one of the failing tests has this error message:
   ```
   Test org.apache.daffodil.general.TestPrimitives.testLengthKindDelimited2 failed: java.lang.Exception: Schema Definition Error: Property dfdl:separator contains disallowed character classes: %WSP;, %WSP;
   ```
   but the dfdl:separator property is allowed to have WSP as a separator. So I think something is off in the latest changes.
   
   > I tried to determine where the unit tests are in the code base, but the paths in the failed check details don't seem to match the paths in the code base.
   
   Are you seeing paths in ``/tmp`` in the error messages? If so, you're probably running into [DAFFODIL-2159](https://issues.apache.org/jira/browse/DAFFODIL-2159) where we show tmp paths instead of actual paths. That's something we just need to get fixed, it's definitely a pain.
   
   To find tests, I usually just use grep. If you use eclipse or IntelliJ there might be an easier way to do it. Bur for example, in the above test error message, we know that the test class is called ``TestPrimitives`` and the test inside that class is called ``testLengthKindDelimited2``. If we grep for the test name:
   ```
   $ grep -R testLengthKindDelimited2 *
   daffodil-core/src/test/scala/org/apache/daffodil/general/TestPrimitives.scala:  @Test def testLengthKindDelimited2: Unit = {
   ```
   We see that this test is defined in ``TestPrimitives.scala``. So we can open that file and find the function to see what it's testing.
   
   Note that this particular test is in daffodil-core, so it's doesn't use any TDML tests. This test is just implemented in code, much like a unit test. Finding TDML tests can require a few more steps. As an example of and how to find a failing TDML test, you also have this as a failing test:
   
   ```
   Error:  Test org.apache.daffodil.section13.nillable.TestNillable.test_entity_fail_06 failed: org.apache.daffodil.tdml.TDMLExceptionImpl: (Implementation: daffodil) Did not find diagnostic message "cannot" in any of the actual diagnostic messages: 
   Error:  Schema Definition Error: Property dfdl:nilValue contains disallowed character classes: %NL;
   ```
   Note that this particular test does look like a case where we just need to update the expected error message. In this case ``TestNillable`` is the class name and the test name is ``test_entity_fail_06``. Grepping for the test name, we get:
   ```
   $ grep -R test_entity_fail_06 *
   daffodil-test/src/test/scala/org/apache/daffodil/section13/nillable/TestNillable.scala:  @Test def test_entity_fail_06(): Unit = { runnerEntity.runOneTest("entity_fail_06") }
   ```
   So this is in the ``TestNillable.scala`` file. We can see it is calling ``runOneTest`` using ``runnerEntity``, with the name of the TDML test case of ``entity_fail_06``. Opening up that file and looking at ``runnerEntity`` and how it's created, we can see that the TDML tests for that runner are in the ``entities_01.tdml`` file in ``/org/apache/daffodil/section06/entities/``. So we can then look in ``daffodil-test/src/test/resources/org/apache/daffodil/section06/entities/entities_01.tdml`` add look for the parserTestCase with name ``entity_fail_06`` to find the inputs and expected outputs/errors of this test.
   
   Note that a shortcut that works in the majority of cases (at least for tests in the daffodil-test project) is to just grep tdml files for the test name with the ``test_`` prefix removed--Scala tests have the prefix, associated TMDL test names do not. So for example, if the test name that failed was "test_fooBarTest_01", then you can just grep for "fooBarTest_01" in all tdml files, for example:
   ```
   $ grep -R fooBarTest_01 --include *.tdml
   ```
   More often than not, that will return one result which is the tdml file the test is in. If it doesn't return anything, you maybe have to take the longer approach mentioned before.


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-768546734


   It might be better to only have one function, but pass in a different regex string to control which entities (NL|ES|WSP|WSP+|WSP*) can throw SDE in the various classes?


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] stevedlawrence commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-767008815


   Welcome!
   
   Though, it looks like this pull request only includes ``.idea/`` files created by IntelliJ. Did you forget to add your changes to the scala files?
   
   Also, as a rule, we don't commit files created by IDEs so we don't have to keep track of everyone's unique editor configurations. Instead, we recommend that you globally ignore those files so you don't accidentally commit them. The default git ignore files to do this are ``$XDG_CONFIG_HOME/git/ignore`` or ``$HOME/.config/git/ignore``. So you could just add ``.idea`` to one of those files.


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] mbeckerle commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
mbeckerle commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-768342231


   Yeah, regex are really hard without myregextester, and the explain regex site tools. 
   
   Here's a regex that matches even number of % followed by single % followed by either NL or ES followed by ";"
   That is, it matches an "unescaped NL" or "unescaped ES".
   
   ```
   (?:%%)*(%(?:NL|ES)\;)
   ```
   You can of course generalize the NL|ES to the set of DFDL entities you want it to exclude. 
   
   Here's a test string:
   ```
   %NL;abcd%%ES;efgh%NLijkl%%%%%NL;mnop
   ```
   And here's the matchAll output as described by myregextester.com
   ```
   $matches Array:
   (
       [0] => Array
           (
               [0] => %NL;
               [1] => %ES;
               [2] => %%%%%NL;
           )
   
       [1] => Array
           (
               [0] => %NL;
               [1] => %ES;
               [2] => %NL;
           )
   
   )
   ```
   And here's the explanation of this per 
   http://rick.measham.id.au/paste/explain.pl?regex=%28%3F%3A%25%25%29*%28%25%28%3F%3ANL%7CES%29%5C%3B%29
   ```
   NODE                     EXPLANATION
   --------------------------------------------------------------------------------
     (?:                      group, but do not capture (0 or more times
                              (matching the most amount possible)):
   --------------------------------------------------------------------------------
       %%                       '%%'
   --------------------------------------------------------------------------------
     )*                       end of grouping
   --------------------------------------------------------------------------------
     (                        group and capture to \1:
   --------------------------------------------------------------------------------
       %                        '%'
   --------------------------------------------------------------------------------
       (?:                      group, but do not capture:
   --------------------------------------------------------------------------------
         NL                       'NL'
   --------------------------------------------------------------------------------
        |                        OR
   --------------------------------------------------------------------------------
         ES                       'ES'
   --------------------------------------------------------------------------------
       )                        end of grouping
   --------------------------------------------------------------------------------
       \;                       ';'
   --------------------------------------------------------------------------------
     )                        end of \1
   ```


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-773978760


   Some of the problems maybe due to duplicate entities ex: %NL;, %ES:, %ES;
   I removed "distinct" from the code because I was getting this compile error:
   value distinct is not a member of Iterator[String]
          val matchedGroups = disallowedRegex.findAllMatchIn(raw).map { _.group(1) }.distinct


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-768393256


   If I use this (?:^|[^%])(?:%%)*(%(?:NL|ES);), only the last item in the test comes back with Some().
   ![image](https://user-images.githubusercontent.com/11149210/106018784-eac06800-608f-11eb-971c-6d727cb39db5.png)
   Is that the desired behavior? Will there always be a ';'?


----------------------------------------------------------------
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



RE: [GitHub] [incubator-daffodil] stevedlawrence commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by Regis Thomas <re...@nteligen.com>.
I made a commit then did a soft reset and re-committed (to put the description in the wiki suggested format), but it looks like the originally committed file reverted back to modified after the reset.  I'll try again.

-----Original Message-----
From: GitBox <gi...@apache.org> 
Sent: Monday, January 25, 2021 1:09 PM
To: commits@daffodil.apache.org
Subject: [GitHub] [incubator-daffodil] stevedlawrence commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"


stevedlawrence commented on pull request #481:
URL: https://usg02.safelinks.protection.office365.us/?url=https%3A%2F%2Fgithub.com%2Fapache%2Fincubator-daffodil%2Fpull%2F481%23issuecomment-767008815&amp;data=04%7C01%7Cregis.thomas%40nteligen.com%7Cb4c0e0d1b8444d3e1e7708d8c15c4f61%7C379c214c5c944e86a6062d047675f02a%7C0%7C0%7C637471949618763394%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=x4PtiAjt2H2qioEdZ%2FFYIcZbSZiw2N0bsGvP%2FCgklVg%3D&amp;reserved=0


   Welcome!
   
   Though, it looks like this pull request only includes ``.idea/`` files created by IntelliJ. Did you forget to add your changes to the scala files?
   
   Also, as a rule, we don't commit files created by IDEs so we don't have to keep track of everyone's unique editor configurations. Instead, we recommend that you globally ignore those files so you don't accidentally commit them. The default git ignore files to do this are ``$XDG_CONFIG_HOME/git/ignore`` or ``$HOME/.config/git/ignore``. So you could just add ``.idea`` to one of those files.


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] stevedlawrence commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-767008815


   Welcome!
   
   Though, it looks like this pull request only includes ``.idea/`` files created by IntelliJ. Did you forget to add your changes to the scala files?
   
   Also, as a rule, we don't commit files created by IDEs so we don't have to keep track of everyone's unique editor configurations. Instead, we recommend that you globally ignore those files so you don't accidentally commit them. The default git ignore files to do this are ``$XDG_CONFIG_HOME/git/ignore`` or ``$HOME/.config/git/ignore``. So you could just add ``.idea`` to one of those files.


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom commented on a change in pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom commented on a change in pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#discussion_r568950951



##########
File path: daffodil-lib/src/main/scala/org/apache/daffodil/cookers/EntityReplacer.scala
##########
@@ -810,7 +809,7 @@ class DelimiterCookerNoES(pn: String) extends ListOfString1OrMoreLiteral(pn, tru
   override val oneLiteralCooker: StringLiteralBase =
     new StringLiteralNoCharClassEntities(propName, true) {
 
-      override protected def noCharClassEntities(raw: String, context: ThrowsSDE): Unit = {
+      override protected def noCharClassEntities(raw: String, disallowedCharClassEntities: String, context: ThrowsSDE): Unit = {
         // TODO: this isn't quite right, as it will allow combined delimiters

Review comment:
       I added the parameter disallowedCharClassEntities here to match the def above, but I am not using the function because of the additional error message test for these items. Perhaps there is a better way to handle this?




----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-768371619


   Results from regex: (^|[^%])(%%)*%NL
   ![image](https://user-images.githubusercontent.com/11149210/106014424-7be11000-608b-11eb-8187-91ada67136a7.png)
   
   Results from regex:  (?:%%)*(%(?:NL|ES)\;)
   ![image](https://user-images.githubusercontent.com/11149210/106014665-afbc3580-608b-11eb-91c3-b3ffd44c4b4e.png)
   
   Possible change:
   context.schemaDefinitionUnless(("(^|[^%])(%%)*%NL".r findFirstIn raw) != None)), str = "Property dfdl:%s cannot contain %%NL;", proprName)
   
   Scala Test:
   import scala.util.matching.Regex
   
   object DfdlTest {
     def main(args: Array[String]) {
       val rawA = Array("%SP,%NL","%%SP,%%NL","%SP,%%NL","%%SP,%%%NL","%SP,%%%NL","%%SP,%%%%NL","%NL","%%NL","%NL;abcd%%ES;efgh%NLijkl%%%%%NL;mnop")
   
       for( raw <- rawA ){
         println(raw + " FFI Result = " + ("(^|[^%])(%%)*%NL".r findFirstIn raw))
   
         if(("(^|[^%])(%%)*%NL".r findFirstIn raw) != None)
           println(raw + " send to SDE")
         else
           println(raw + " allowed")
       }
     }
   }
   
   


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-766999733


   I am a newbie to Daffodil and Scala.  I'm not sure if this was the best way to handle this request.  Also not sure if I should have had the if statement wrap the other 4 strings in the function.  Any feedback or suggestions are welcome.


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] stevedlawrence commented on a change in pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on a change in pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#discussion_r569001136



##########
File path: daffodil-lib/src/main/scala/org/apache/daffodil/cookers/EntityReplacer.scala
##########
@@ -565,43 +565,59 @@ trait NoCharClassEntitiesMixin {
   protected def propName: String
 
   /**
-   * Override if set of prohibited class entities is different
+   * The raw string to test is supplied as the first parameter
+   * A list of disallowed character class entities is supplied as the 2nd parameter
+   * This list is added to the regex string below
+   * Ex regex: (?:^|[^%])(?:%%)*(%(?:NL|ES);)
+   * (?:^|[^%]) look for the beginning of the string or a non-% character
+   * (?:%%)* look for an even number of %'s
+   * (%(?:NL|ES);) look for any single % left after previous match along with and NL or ES followed by a ;
+   *
    */
-  protected def noCharClassEntities(raw: String, context: ThrowsSDE): Unit = {
-    context.schemaDefinitionUnless(!raw.contains("%NL;"), "Property dfdl:%s cannot contain %%NL;", propName)
-    context.schemaDefinitionUnless(!raw.contains("%ES;"), "Property dfdl:%s cannot contain %%ES;", propName)
-    context.schemaDefinitionUnless(!raw.contains("%WSP;"), "Property dfdl:%s cannot contain %%WSP;", propName)
-    context.schemaDefinitionUnless(!raw.contains("%WSP+;"), "Property dfdl:%s cannot contain %%WSP+;", propName)
-    context.schemaDefinitionUnless(!raw.contains("%WSP*;"), "Property dfdl:%s cannot contain %%WSP*;", propName)
-  }
-
-  protected def testRaw(raw: String, context: ThrowsSDE): Unit = {
-    noCharClassEntities(raw, context)
+  protected def noCharClassEntities(raw: String, disallowedCharClassEntities: String,
+                                    context: ThrowsSDE): Unit = {
+    // if there is an odd number of '%' continue with the SDE
+    val regexString = "(?:^|[^%])(?:%%)*(%(?:" + disallowedCharClassEntities + ");)"
+    val noCharClassEntitiesRegex = regexString.r
+    val matchedGroups = noCharClassEntitiesRegex.findAllMatchIn(raw).map {_.group(1)}
+    context.schemaDefinitionUnless(
+      matchedGroups.isEmpty,
+      "Property dfdl:%s contains disallowed character classes: %s" ,
+      propName,
+      matchedGroups.mkString(", "))
+  }
+
+  protected def testRaw(raw: String, disallowedCharClassEntities: String, context: ThrowsSDE): Unit = {
+    noCharClassEntities(raw, "NL|ES|WSP|WSP+|WSP*", context)
   }

Review comment:
       I would avoid passing in things to testRaw, that should really only passing in the raw string, and then implementations of testRaw need to have the information for how to perform the raw test provided some other way. I'm also not a huge fan of the parameter being a string of entities separated by pipes, since it sort of implies it's being inserted into a regex. I think a Seq of strings is a little easierto visually scan, and is easier to change it the regex changes in the future.
   
   What if instead we do something to how propName is used in this trait:
   
   ```scala
   trait DisallowedCharClassEntitiesMixin {
     protected def propName: String
     protected def disallowedCharClassEntities: Seq[String]
   
     private lazy val disalllowedRegex = {
       val disallowedCharClassMatch = disallowedCharClassEntities.mkstring("|")
       val regexString = "(?:^|[^%])(?:%%)*(%(?:" + disallowedCharClassMatch + ");)"
       regexString.r
     }
   
     protected def testRaw(raw:String, context: ThrowsSDE): Unit = {
       val matchedGroup = disallowedRegex.finaAllMatchIn(raw).map { _.group(1) }
       conext.schemaDefinitionUnless(...)
     }
   }
   ```
   So this renames the trait to be a bit more descriptive about what it's really doing, since it isn't about "No" entities, but "Disallowed" entities. It also adds adds an abstract def ``disallowedCharClassEntities`` member that things that mix in this trait must implement to say what the disallowed entities are. Using this member, it builds and saves a regex (so it doesn't have to rebuild and compile it every time it's used). And the testRaw function has all the logic for actually testing and creating SDE's. The noCharClassEntities function isn't really needed anymore.
   
   Then things that implement this trait just have to set that one member, e.g.
   
   ```scala
   class StringLiteralNoCharClassEntities
     extends ...
     with DisallowedCharClassEntitiesMixin {
     
     override val disallowedCharClassEntities = Seq("NL", "ES", "WSP", "WSP+", "WSP*")
   
     ...
   }
   ```




----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] stevedlawrence commented on a change in pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on a change in pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#discussion_r569001136



##########
File path: daffodil-lib/src/main/scala/org/apache/daffodil/cookers/EntityReplacer.scala
##########
@@ -565,43 +565,59 @@ trait NoCharClassEntitiesMixin {
   protected def propName: String
 
   /**
-   * Override if set of prohibited class entities is different
+   * The raw string to test is supplied as the first parameter
+   * A list of disallowed character class entities is supplied as the 2nd parameter
+   * This list is added to the regex string below
+   * Ex regex: (?:^|[^%])(?:%%)*(%(?:NL|ES);)
+   * (?:^|[^%]) look for the beginning of the string or a non-% character
+   * (?:%%)* look for an even number of %'s
+   * (%(?:NL|ES);) look for any single % left after previous match along with and NL or ES followed by a ;
+   *
    */
-  protected def noCharClassEntities(raw: String, context: ThrowsSDE): Unit = {
-    context.schemaDefinitionUnless(!raw.contains("%NL;"), "Property dfdl:%s cannot contain %%NL;", propName)
-    context.schemaDefinitionUnless(!raw.contains("%ES;"), "Property dfdl:%s cannot contain %%ES;", propName)
-    context.schemaDefinitionUnless(!raw.contains("%WSP;"), "Property dfdl:%s cannot contain %%WSP;", propName)
-    context.schemaDefinitionUnless(!raw.contains("%WSP+;"), "Property dfdl:%s cannot contain %%WSP+;", propName)
-    context.schemaDefinitionUnless(!raw.contains("%WSP*;"), "Property dfdl:%s cannot contain %%WSP*;", propName)
-  }
-
-  protected def testRaw(raw: String, context: ThrowsSDE): Unit = {
-    noCharClassEntities(raw, context)
+  protected def noCharClassEntities(raw: String, disallowedCharClassEntities: String,
+                                    context: ThrowsSDE): Unit = {
+    // if there is an odd number of '%' continue with the SDE
+    val regexString = "(?:^|[^%])(?:%%)*(%(?:" + disallowedCharClassEntities + ");)"
+    val noCharClassEntitiesRegex = regexString.r
+    val matchedGroups = noCharClassEntitiesRegex.findAllMatchIn(raw).map {_.group(1)}
+    context.schemaDefinitionUnless(
+      matchedGroups.isEmpty,
+      "Property dfdl:%s contains disallowed character classes: %s" ,
+      propName,
+      matchedGroups.mkString(", "))
+  }
+
+  protected def testRaw(raw: String, disallowedCharClassEntities: String, context: ThrowsSDE): Unit = {
+    noCharClassEntities(raw, "NL|ES|WSP|WSP+|WSP*", context)
   }

Review comment:
       I would avoid passing in things to testRaw, that should really only passing in the raw string, and then implementations of testRaw need to have the information for how to perform the raw test provided some other way. I'm also not a huge fan of the parameter being a string of entities separated by pipes, since it sort of implies it's being inserted into a regex. I think a Seq of strings is a little easierto visually scan, and is easier to change it the regex changes in the future.
   
   What if instead we do something to how propName is used in this trait:
   
   ```scala
   trait DisallowedCharClassEntitiesMixin {
     protected def propName: String
     protected def disallowedCharClassEntities: Seq[String]
   
     private lazy val disalllowedRegex = {
       val disallowedCharClassMatch = disallowedCharClassEntities.mkstring("|")
       val regexString = "(?:^|[^%])(?:%%)*(%(?:" + disallowedCharClassMatch + ");)"
       regexString.r
     }
   
     protected def testRaw(raw:String, context: ThrowsSDE): Unit = {
       val matchedGroup = disallowedRegex.finaAllMatchIn(raw).map { _.group(1) }
       conext.schemaDefinitionUnless(...)
     }
   }
   ```
   So this renames the trait to be a bit more descriptive about what it's really doing, since it isn't about "No" entities, but "Disallowed" entities. It also adds adds an abstract def ``disallowedCharClassEntities`` member that things that mix in this trait must implement to say what the disallowed entities are. Using this member, it builds and saves a regex (so it doesn't have to rebuild and compile it every time it's used). And the testRaw function has all the logic for actually testing and creating SDE's. The noCharClassEntities function isn't really needed anymore.
   
   Then things that implement this trait just have to set that one member, e.g.
   
   ```scala
   class StringLiteralNoCharClassEntities
     extends ...
     with DisallowedCharClassEntitiesMixin {
     
     override val disallowedCharClassEntities = Seq("NL", "ES", "WSP", "WSP+", "WSP*")
   
     ...
   }
   ```




----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-768277769


   I wasn't sure how to accomplish the even/odd requirement with regex, but I did come up with this:  context.schemaDefinitionUnless((!raw.contains("%NL;")) && !(raw.count(_ == '%') % 2 ==0)), str = "Property dfdl:%s cannot contain %%NL;", proprName)
   
   I tested the results with this simple scala snippet:
   object DfdlTest {
     def main(args: Array[String]) {
       val raw1 = "%%%NL";
       val raw2 = "%%%%NL";
     
       if(!(raw1.count(_== '%') % 2 == 0) && !(raw1.contains("%NL;")))
         println("raw1 = " + raw1 + " allowed")
       else
         println("raw1 = " + raw1 + " not allowed")
   
       if(!(raw2.count(_== '%') % 2 == 0) && !(raw2.contains("%NL;")))
         println("raw2 = " + raw2 + " allowed")
       else
         println("raw2 = " + raw2 + " not allowed")
     }
   }
   Let me know if this would be an acceptable solution or if I should do some further research toward a regex solution.


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] stevedlawrence commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-774016926


   > I removed "distinct" from the code because I was getting this compile error:
   > value distinct is not a member of Iterator[String]
   
   Scala 2.12 doesn't have the ``distinct`` function on the ``Iterator`` trait. The easiest way to get around this to to just convert the ``Iterator`` to a ``Seq``. This list will always be small enough (or even zero length in most cases) that this conversion shouldn't matter performance-wise.
   
   ``scala
   val matchedGroups = disallowedRegex.findAllMatchIn(raw).map { _.group(1) }.toSeq.distinct
   ```


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-769737532


   I will look at making the suggested changes (including to Jira ticket) and re-commit the changes when done.  Should I also look at adding additional tests in TDML?  I am not familiar with TDML is there somewhere you could point me to to get the basics?


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-768538310


   OK


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] stevedlawrence commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-768295894


   I think an issue with that approach is that you can have multiple character classes in these property strings. For example:
   ```xml
   <xs:element ... dfdl:textStandardZeroRep="%SP;%NL;" />
   ```
   This is a space character followed by a newline. This shouldn't be allowed because ``%NL;`` is an unescaped newline, but in this case the count of ``%``'s is even so will be incorrectly allowed. So it's not just the count of ``%``'s that matters, but the count of all ``%``'s immediately preceeding an ``%NL;``. I think the following regex will do that (though, not heavily tested):
   ```regex
   (^|[^%])(%%)*%NL;
   ```
   So first we look for either the beginning of the string or a non-``%`` character with ``(^|[^%])``. Following that, we look for an even number of ``%``'s with ``(%%)*``. And finally following that we look for a ``%NL;``. I think that should match any ``%NL;`` not immediately preceeded by an even number of ``%``'s, in other words, an unescaped ``%NL;``.


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] stevedlawrence commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-768517115


   What you have first looks right to me. I'm not sure we need the double %% in the error message. The issue is that there is an invalid character class. That fact that there are a zero or more escaped percents preceeding it doesn't really matter. The ``%NL;`` is the only invalid part.
   
   There is maybe an argument that if there were a bunch of extra percents, that maybe the user just messed up their escaping, so we could give a warning to that effect, but I'm not sure that's really necessary and adds more complication--we would then need to capture the extra percents as well.
   
   Also, it might make sense to use ``.distinct`` so we don't show the same character class multiple times in the warning, e.g.:
   ```scala
   r.findAllMatchIn(raw).map { _.group(1) }.distinct
   ```
   I'm not sure the duplication adds value and is potential confusing.


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-768461099


   I get this error:
   ![image](https://user-images.githubusercontent.com/11149210/106030643-61fbf900-609c-11eb-89dd-a5ac94723235.png)
   The compile is successful if I remove ".map { _.group(1) }"
   In testing (with ".map { _.group }" removed) I get results like:
   ![image](https://user-images.githubusercontent.com/11149210/106031232-0a11c200-609d-11eb-994c-c3adc0702e4c.png)
   The original function calls hardcoded the character classes like "%%NL;" or "%%ES;" in the parameters.
   In the test result instances smoetimes there is only one '%". Other times there can be more than two.  Should I format the results to take only the last three character (ex "NL;") and prepend two '%'?


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] mbeckerle commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
mbeckerle commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-768404665


   Suggestion for not only this PR, but in the future, I think we should cut/paste the result of the regex explain into comments in the code to document the intention of the regex. 
   
   The regex explanation is from http://rick.measham.id.au/paste/explain.pl


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom edited a comment on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom edited a comment on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-773963265


   I took a look at why all the checks failed.  Unit tests are expecting results back like:
   "cannot contain %ES;"
   With the modifications, the wording for the new results has changed and the entities are combined:
   Property dfdl:test contains disallowed character classes: %NL;, %ES;
   I tried to determine where the unit tests are in the code base, but the paths in the failed check details don't seem to match the paths in the code base.


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] stevedlawrence commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-768374198


   Mike, nice improvement, the non-capture group stuff is nice and makes it easy to find and extract all unescaped character classes in a single regex. Could avoid a lot of duplication. Though, I think in your example the ``%ES;`` shouldn't be matched since that percent is escaped? The ``(^|[^%])`` trick should fix that I think? Adding that in and making it a non-capture group gives this regex:
   ```
   (?:^|[^%])(?:%%)*(%(?:NL|ES)\;)
   ```
   It's a bit ugly, but a single regex to capture all relevant information is nice, and documenting this isn't too terrible.


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] stevedlawrence edited a comment on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
stevedlawrence edited a comment on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-774016926


   > I removed "distinct" from the code because I was getting this compile error:
   > value distinct is not a member of Iterator[String]
   
   Scala 2.12 doesn't have the ``distinct`` function on the ``Iterator`` trait. The easiest way to get around this to to just convert the ``Iterator`` to a ``Seq``. This list will always be small enough (or even zero length in most cases) that this conversion shouldn't matter performance-wise.
   
   ```scala
   val matchedGroups = disallowedRegex.findAllMatchIn(raw).map { _.group(1) }.toSeq.distinct
   ```


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] stevedlawrence commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-768397840


   Yes, there will also be a semicolon for a character class to be seen as a character class. If you just had something like ``%NLfoo``, you'll get a different error somewhere else that's something like ``found a ` that isn't followed by a valid character class``. That check happens elsewhere, so you shouldn't have to worry about that in this check. For this regex, you can assume the semicolon always exists since we're only looking for known character classes that aren't allowed.


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-766999733


   I am a newbie to Daffodil and Scala.  I'm not sure if this was the best way to handle this request.  Also not sure if I should have had the if statement wrap the other 4 strings in the function.  Any feedback or suggestions are welcome.


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] mbeckerle commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
mbeckerle commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-771714932


   If the code is self explanatory, because the lists of allowed/disallowed entities are explicitly sitting there, then yeah, no comments are needed. Given a list of them though, it may not be obvious which one is not there. So a comment like // Not ES
   may be helpful.
   Alternatively you can do something like:
   ```
   val entitiesWithoutES = Seq("%NL;", ....)
   ```
   To make it self-documenting without using comments.
   
   But in general, push your changes and let's see how it is coming out. 
   I often push changes and immediately put some comments on the PR myself to ask people what they think about this or that aspect. Just like your question here. 


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-768510159


   findAllMatchIn works with .map { _.group(1) }
   test results now look like this:
   Property dfdl:test contains disallowed character classes: %NL;, %NL;
   Property dfdl:test contains disallowed character classes: %ES;
   Property dfdl:test contains disallowed character classes: %NL;, %WSP;, %NL;
   by changing:
     "Property dfdl:%s contains disallowed character classes: %s", propName, matchedGroups.mkString(", "))
   to
     "Property dfdl:%s contains disallowed character classes: %%%s", propName, matchedGroups.mkString(", %"))
   I was able to get this:
   Property dfdl:test contains disallowed character classes: %%NL;, %%NL;
   Property dfdl:test contains disallowed character classes: %%ES;
   Property dfdl:test contains disallowed character classes: %%NL;, %%WSP;, %%NL;


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] stevedlawrence commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-768389313


   I think that semicolon just shouldn't be escaped. That's not a special character in regex so doesn't need escaping:
   ```
   (?:^|[^%])(?:%%)*(%(?:NL|ES);)
   ```


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] mbeckerle commented on a change in pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
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



[GitHub] [incubator-daffodil] mbeckerle commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
mbeckerle commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-769843371


   https://daffodil.apache.org/tdml/
   (I am happy to report that google found that for me.)
   
   In the daffodil tree, the daffodil-test module is basically a big project containing almost entirely TDML tests. 
   
   There are probably existing tests related to this feature and you can add tests to that test file, or copy the scala code driver file (which are just a JUInit thing that drives a TDML test as a JUnit test) and modify to make a new one to just drive a single TDML file with just your tests in it. 
   
   Tests of textStandardZeroRep are in the scala driver file
   src/test/scala/org/apache/daffodil/section13/text_number_props/TestTextNumberProps.scala
   e.g.,  test_standardZeroRep01 to test_standardZeroRep11.
   
   The corresponding TDML file is in the analogous
   src/test/resources/..../section13/text_number_props/TextNumberProps.tdml
   
   This file is pretty big, but I think it makes sense to just make sure the tests here cover the corner cases. 
   
   I don't know what IDE you use, but in both Eclipse and IntelliJ IDEA, you can right click on the scala def of a test, and run exadtly that one test or debug exactly that one test. This is the primary way I debug and test daffodil. 
   
   


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom commented on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom commented on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-773963265


   Ii took at look at why all the checks failed.  Unit test are expecting results back like:
   "cannot contain %ES;"
   With the modifications, the wording for the new results has changed and the entities are combined:
   Property dfdl:test contains disallowed character classes: %NL;, %ES;
   I tried to determine where the unit tests are in the code base, but the paths in the failed check details don't seem to match the paths in the code base.


----------------------------------------------------------------
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



[GitHub] [incubator-daffodil] regetom edited a comment on pull request #481: ADD test for "%%" to bypass existing test for "%NL"

Posted by GitBox <gi...@apache.org>.
regetom edited a comment on pull request #481:
URL: https://github.com/apache/incubator-daffodil/pull/481#issuecomment-773963265


   Ii took at look at why all the checks failed.  Unit tests are expecting results back like:
   "cannot contain %ES;"
   With the modifications, the wording for the new results has changed and the entities are combined:
   Property dfdl:test contains disallowed character classes: %NL;, %ES;
   I tried to determine where the unit tests are in the code base, but the paths in the failed check details don't seem to match the paths in the code base.


----------------------------------------------------------------
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