fix: csv: fix regression in parsing rules containing & (#2352)
This commit is contained in:
parent
5d4631bfda
commit
a8a0d3ee30
@ -723,7 +723,7 @@ regexp end = do
|
||||
Left x -> Fail.fail $ "CSV parser: " ++ x
|
||||
Right x -> return x
|
||||
where
|
||||
double_ampersand = lookAhead . void $ char '&' >> char '&'
|
||||
double_ampersand = lookAhead . void $ string "&&"
|
||||
|
||||
-- -- A match operator, indicating the type of match to perform.
|
||||
-- -- Currently just ~ meaning case insensitive infix regex match.
|
||||
@ -1596,9 +1596,14 @@ tests_RulesReader = testGroup "RulesReader" [
|
||||
-- parseWithState' defrules matcherp "%description ~ A A\n" @?= (Right $ FieldMatcher "%description" "A A")
|
||||
]
|
||||
|
||||
|
||||
,testGroup "regexp" [
|
||||
testCase "regexp.ends-before-&&" $
|
||||
parseWithState' defrules (regexp empty) "A A && xxx" @?= (Right $ toRegexCI' "A A")
|
||||
parseWithState' defrules (regexp eof) "A A && xxx" @?= (Right $ toRegexCI' "A A")
|
||||
,testCase "regexp contains &" $
|
||||
parseWithState' defrules (regexp eof) "A & B" @?= (Right $ toRegexCI' "A & B")
|
||||
,testCase "regexp contains escaped &" $
|
||||
parseWithState' defrules (regexp eof) "A \\& B" @?= (Right $ toRegexCI' "A \\& B")
|
||||
]
|
||||
|
||||
, let matchers = [RecordMatcher Or (toRegexCI' "A"), RecordMatcher And (toRegexCI' "B")]
|
||||
|
||||
@ -1203,6 +1203,33 @@ $ ./csvtest.sh
|
||||
|
||||
>=0
|
||||
|
||||
# ** 62. Matchers can contain '&', either escaped or unescaped (#2352)
|
||||
<
|
||||
2025-01-01,STOP & SHOP,100
|
||||
2025-01-01,H & M,100
|
||||
|
||||
RULES
|
||||
fields date,description,amount
|
||||
|
||||
if
|
||||
%description STOP & SHOP
|
||||
account1 expenses:food
|
||||
|
||||
if
|
||||
%description H \& M
|
||||
account1 expenses:clothing
|
||||
|
||||
$ ./csvtest.sh
|
||||
2025-01-01 STOP & SHOP
|
||||
expenses:food 100
|
||||
income:unknown -100
|
||||
|
||||
2025-01-01 H & M
|
||||
expenses:clothing 100
|
||||
income:unknown -100
|
||||
|
||||
>=
|
||||
|
||||
# ** .
|
||||
#<
|
||||
#$ ./csvtest.sh
|
||||
|
||||
Loading…
Reference in New Issue
Block a user