Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d59afa4

Browse files
authoredJan 8, 2025··
Merge pull request #146 from tomek12311/fix/question-marks-are-not-parsed-correctly
FIX: Question marks are not parsed correctly
2 parents 385dd28 + 55eb38a commit d59afa4

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed
 

‎src/EDI/Parser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,10 @@ private function unwrap(string &$string): array
522522
$this->errors[] = 'This file contains some segments without terminators';
523523
}
524524

525-
$terminatorRegex = '/(([^'.$this->symbRel.']'.$this->symbRel.'{2})+|[^'.$this->symbRel.'])'.$this->symbEnd.'|[\r\n]+/';
525+
$terminatorRegex = '/((?<!'.$this->symbRel.')(?:'.$this->symbRel.$this->symbRel.')*)'.$this->symbEnd.'|[\r\n]+/';
526526

527527
if ($this->strict) {
528-
$terminatorRegex = '/(([^'.$this->symbRel.']'.$this->symbRel.'{2})+|[^'.$this->symbRel.'])'.$this->symbEnd.'/';
528+
$terminatorRegex = '/((?<!'.$this->symbRel.')(?:'.$this->symbRel.$this->symbRel.')*)'.$this->symbEnd.'/';
529529
}
530530

531531
$string = (string) \preg_replace(

‎tests/EDITest/ParserTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ public static function multipleEscapedSegmentsProvider(): array
9090
["EQD+CX??????DU12?+3456+2?:0'", [['EQD', 'CX???DU12+3456', '2:0']]],
9191
["EQD+CX????????DU12?+3456+2?:0'", [['EQD', 'CX????DU12+3456', '2:0']]],
9292
["EQD+CX??DU12?+3456+2?:0??'", [['EQD', 'CX?DU12+3456', '2:0?']]],
93-
["EQD+CX??DU12?+3456+2?:0????'", [['EQD', 'CX?DU12+3456', "2:0??'"]]], // TODO? -> ' is correct here?
94-
["EQD+CX??DU12?+3456+2?:0??????'", [['EQD', 'CX?DU12+3456', "2:0???'"]]], // TODO? -> ' is correct here?
93+
["EQD+CX??DU12?+3456+2?:0???'", [['EQD', 'CX?DU12+3456', "2:0?'"]]],
94+
["EQD+CX??DU12?+3456+2?:0????'", [['EQD', 'CX?DU12+3456', "2:0??"]]],
95+
["EQD+CX??DU12?+3456+2?:0??????'", [['EQD', 'CX?DU12+3456', "2:0???"]]],
96+
["EQD+CX??DU12?+3456+2?:0???????'", [['EQD', 'CX?DU12+3456', "2:0???'"]]],
9597
["??EQD+CX??DU12?+3456+2?:0'", [['?EQD', 'CX?DU12+3456', '2:0']]],
9698
["????EQD+CX??DU12?+3456+2?:0'", [['??EQD', 'CX?DU12+3456', '2:0']]],
9799
["??????EQD+CX??DU12?+3456+2?:0'", [['???EQD', 'CX?DU12+3456', '2:0']]],

0 commit comments

Comments
 (0)
Please sign in to comment.