This is an automated email from the ASF dual-hosted git repository.

slawrence pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil.git


The following commit(s) were added to refs/heads/main by this push:
     new 059279320 Fix dropping characters from escapeBlockStart partial matches
059279320 is described below

commit 059279320a71bdc61b3a6c928ccddf8988ba1332
Author: Steve Lawrence <[email protected]>
AuthorDate: Wed Oct 15 07:28:13 2025 -0400

    Fix dropping characters from escapeBlockStart partial matches
    
    If a field defines escapeKind="escapeBlock" but looking for the
    escapeBlockStart characters has a partial match (i.e. it matches one or
    more escapeBlockStart characters but not the whole string), then we
    accidentally drop the characters that partially matched. This is because
    we do not reset the bit position back to where we started the scan.
    
    The fix to this is to mark the current position before scan for a block
    start, and if the scan fails then reset back to the original mark
    position and do normal delimiter scanning to capture the field
    characters.
    
    DAFFODIL-1392
---
 .../daffodil/runtime1/processors/dfa/TextDelimitedParser.scala     | 2 ++
 .../src/test/resources/test-suite/tresys-contributed/BA.tdml       | 7 ++++---
 .../src/test/scala/org/apache/daffodil/TresysTests.scala           | 4 +---
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git 
a/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/processors/dfa/TextDelimitedParser.scala
 
b/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/processors/dfa/TextDelimitedParser.scala
index 6b93f6db1..b7aaeb580 100644
--- 
a/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/processors/dfa/TextDelimitedParser.scala
+++ 
b/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/processors/dfa/TextDelimitedParser.scala
@@ -413,8 +413,10 @@ class TextDelimitedParserWithEscapeBlock(
     Assert.invariant(endBlock != null)
 
     removeLeftPadding(state, input, delimIter)
+    val beforeStartBlock = input.markPos
     val foundStartBlock = parseStartBlock(state, input, startBlock, delimIter)
     val res = if (!foundStartBlock) {
+      input.resetPos(beforeStartBlock)
       super.parse(state, input, field, delimIter, isDelimRequired)
     } else {
       parseRemainder(state, input, fieldEsc, startBlock, endBlock, delimIter, 
isDelimRequired)
diff --git 
a/daffodil-test-ibm1/src/test/resources/test-suite/tresys-contributed/BA.tdml 
b/daffodil-test-ibm1/src/test/resources/test-suite/tresys-contributed/BA.tdml
index 247b4fdf4..1ea6e975f 100644
--- 
a/daffodil-test-ibm1/src/test/resources/test-suite/tresys-contributed/BA.tdml
+++ 
b/daffodil-test-ibm1/src/test/resources/test-suite/tresys-contributed/BA.tdml
@@ -18,7 +18,8 @@
 
 <testSuite suiteName="BA" xmlns="http://www.ibm.com/xmlns/dfdl/testData";
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:ct="http://w3.ibm.com/xmlns/dfdl/ctInfoset";
-  defaultImplementations="ibm daffodil">
+  defaultImplementations="ibm daffodil"
+  xmlns:ex="http://example.com";>
 
   <parserTestCase name="BA000" root="list" model="BA.dfdl.xsd"
     description="Schema Escaping: escape escape character, variable length">
@@ -30,7 +31,7 @@
 ]]></document>
     <infoset>
       <dfdlInfoset>
-        <list xmlns="http://www.example.org/example1";>
+        <ex:list xmlns="http://www.example.org/example1";>
           <character1>item1</character1>
           <character1>item,2</character1>
           <character1>item#3</character1>
@@ -58,7 +59,7 @@
           <!-- So according to the DFDL Spec 13.2.1 discussion of the 
dfdl:escapeKind property, this escapeEscape should be preserved in the data. -->
           <block2>,,6</block2>
           <block2>START777END</block2>
-        </list>
+        </ex:list>
       </dfdlInfoset>
     </infoset>
   </parserTestCase>
diff --git 
a/daffodil-test-ibm1/src/test/scala/org/apache/daffodil/TresysTests.scala 
b/daffodil-test-ibm1/src/test/scala/org/apache/daffodil/TresysTests.scala
index b731d6eb3..97cc306f5 100644
--- a/daffodil-test-ibm1/src/test/scala/org/apache/daffodil/TresysTests.scala
+++ b/daffodil-test-ibm1/src/test/scala/org/apache/daffodil/TresysTests.scala
@@ -208,9 +208,7 @@ class TestAZ extends TdmlTests {
 class TestBA extends TdmlTests {
   val tdmlSuite = TestBA
 
-  // Jira DFDL-1392 - Issue with escapeEscape character that is first and 
precedes an escape-block start.
-  // Is being removed, but should be preserved as it does not precede an 
escape character, nor an escape block end.
-  @Ignore @Test def BA000 = test
+  @Test def BA000 = test
 }
 
 class TestBB extends TdmlTests {

Reply via email to