Skip to content

Commit 7e8c711

Browse files
committed
Fix an issue where $ in regular expressions in Substitution filters would not always work correctly if the "Ignore carriage return differences" option was enabled. (refs #2640)
1 parent a678745 commit 7e8c711

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

Externals/poco/Foundation/include/Poco/RegularExpression.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class Foundation_API RegularExpression
7070
RE_NEWLINE_CRLF = 0x00300000, /// assume newline is CRLF ("\r\n") [ctor]
7171
RE_NEWLINE_ANY = 0x00400000, /// assume newline is any valid Unicode newline character [ctor]
7272
RE_NEWLINE_ANYCRLF = 0x00500000, /// assume newline is any of CR, LF, CRLF [ctor]
73+
RE_NEWLINE_MASK = 0x00F00000,
7374
RE_GLOBAL = 0x10000000, /// replace all occurences (/g) [subst]
7475
RE_NO_VARS = 0x20000000 /// treat dollar in replacement string as ordinary character [subst]
7576
};

Externals/poco/Foundation/src/RegularExpression.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ RegularExpression::RegularExpression(const std::string& pattern, int options, bo
7575
pcre2_compile_context* context = pcre2_compile_context_create(nullptr);
7676
if (!context) throw Poco::RegularExpressionException("cannot create compile context");
7777

78-
if (options & RE_NEWLINE_LF)
78+
if ((options & RE_NEWLINE_MASK) == RE_NEWLINE_LF)
7979
pcre2_set_newline(context, PCRE2_NEWLINE_LF);
80-
else if (options & RE_NEWLINE_CRLF)
80+
else if ((options & RE_NEWLINE_MASK) == RE_NEWLINE_CRLF)
8181
pcre2_set_newline(context, PCRE2_NEWLINE_CRLF);
82-
else if (options & RE_NEWLINE_ANY)
82+
else if ((options & RE_NEWLINE_MASK) == RE_NEWLINE_ANY)
8383
pcre2_set_newline(context, PCRE2_NEWLINE_ANY);
84-
else if (options & RE_NEWLINE_ANYCRLF)
84+
else if ((options & RE_NEWLINE_MASK) == RE_NEWLINE_ANYCRLF)
8585
pcre2_set_newline(context, PCRE2_NEWLINE_ANYCRLF);
8686
else // default RE_NEWLINE_CR
8787
pcre2_set_newline(context, PCRE2_NEWLINE_CR);

Src/SubstitutionFiltersList.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ std::shared_ptr<SubstitutionList> SubstitutionFiltersList::MakeSubstitutionList(
261261
ucr::toUTF8(item.pattern),
262262
ucr::toUTF8(item.replacement),
263263
(item.caseSensitive ? 0 : Poco::RegularExpression::RE_CASELESS) |
264-
Poco::RegularExpression::RE_MULTILINE);
264+
Poco::RegularExpression::RE_MULTILINE | Poco::RegularExpression::RE_NEWLINE_ANYCRLF);
265265
}
266266
else
267267
{

0 commit comments

Comments
 (0)