fix: a regex bug with escaping inside of character classes (#4575)

Also delete the broken docker weekly flow.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
Roman Gershman
2025-02-07 12:42:45 +02:00
committed by GitHub
parent b0b9a72dbd
commit acde373709
3 changed files with 13 additions and 29 deletions

View File

@ -1,25 +0,0 @@
name: weekly docker build
on:
schedule:
# Monday midnight
- cron: '0 0 * * 1'
workflow_dispatch:
permissions:
packages: write
contents: write
id-token: write
jobs:
weekly-container-build:
uses: ./.github/workflows/reusable-container-workflow.yaml
with:
build_type: dev
tag: ${{ github.sha}}
tag_latest: true
image: ghcr.io/dragonflydb/dragonfly-weekly
registry: ghcr.io
registry_username: ${{ github.repository_owner }}
secrets:
registry_password: ${{ secrets.GITHUB_TOKEN }}

View File

@ -230,7 +230,7 @@ TEST_F(IntentLockTest, Basic) {
class StringMatchTest : public ::testing::Test {
protected:
// wrapper around stringmatchlen with stringview arguments
int MatchLen(string_view pattern, string_view str, bool nocase) {
bool MatchLen(string_view pattern, string_view str, bool nocase) {
GlobMatcher matcher(pattern, !nocase);
return matcher.Matches(str);
}
@ -247,6 +247,11 @@ TEST_F(StringMatchTest, Glob2Regex) {
EXPECT_EQ(GlobMatcher::Glob2Regex("[^]a"), ".a");
EXPECT_EQ(GlobMatcher::Glob2Regex("[]a"), "[]a");
EXPECT_EQ(GlobMatcher::Glob2Regex("\\d"), "d");
EXPECT_EQ(GlobMatcher::Glob2Regex("[\\d]"), "[\\\\d]");
reflex::Matcher matcher("abc[\\\\d]e");
matcher.input("abcde");
ASSERT_TRUE(matcher.find());
}
TEST_F(StringMatchTest, Basic) {
@ -289,9 +294,10 @@ TEST_F(StringMatchTest, Basic) {
}
TEST_F(StringMatchTest, Special) {
EXPECT_EQ(MatchLen("h\\[^|", "h[^|", 0), 1);
EXPECT_EQ(MatchLen("[^", "[^", 0), 0);
EXPECT_EQ(MatchLen("[$?^]a", "?a", 0), 1);
EXPECT_TRUE(MatchLen("h\\[^|", "h[^|", 0));
EXPECT_FALSE(MatchLen("[^", "[^", 0));
EXPECT_TRUE(MatchLen("[$?^]a", "?a", 0));
EXPECT_TRUE(MatchLen("abc[\\d]e", "abcde", 0));
}
using benchmark::DoNotOptimize;

View File

@ -31,6 +31,9 @@ string GlobMatcher::Glob2Regex(string_view glob) {
in_group = 0;
}
regex.push_back(c);
if (c == '\\') {
regex.push_back(c); // escape it.
}
continue;
}