mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
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:
parent
b0b9a72dbd
commit
acde373709
3 changed files with 13 additions and 29 deletions
25
.github/workflows/docker-weekly.yml
vendored
25
.github/workflows/docker-weekly.yml
vendored
|
@ -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 }}
|
|
|
@ -230,7 +230,7 @@ TEST_F(IntentLockTest, Basic) {
|
||||||
class StringMatchTest : public ::testing::Test {
|
class StringMatchTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
// wrapper around stringmatchlen with stringview arguments
|
// 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);
|
GlobMatcher matcher(pattern, !nocase);
|
||||||
return matcher.Matches(str);
|
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("[]a"), "[]a");
|
EXPECT_EQ(GlobMatcher::Glob2Regex("[]a"), "[]a");
|
||||||
EXPECT_EQ(GlobMatcher::Glob2Regex("\\d"), "d");
|
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) {
|
TEST_F(StringMatchTest, Basic) {
|
||||||
|
@ -289,9 +294,10 @@ TEST_F(StringMatchTest, Basic) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(StringMatchTest, Special) {
|
TEST_F(StringMatchTest, Special) {
|
||||||
EXPECT_EQ(MatchLen("h\\[^|", "h[^|", 0), 1);
|
EXPECT_TRUE(MatchLen("h\\[^|", "h[^|", 0));
|
||||||
EXPECT_EQ(MatchLen("[^", "[^", 0), 0);
|
EXPECT_FALSE(MatchLen("[^", "[^", 0));
|
||||||
EXPECT_EQ(MatchLen("[$?^]a", "?a", 0), 1);
|
EXPECT_TRUE(MatchLen("[$?^]a", "?a", 0));
|
||||||
|
EXPECT_TRUE(MatchLen("abc[\\d]e", "abcde", 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
using benchmark::DoNotOptimize;
|
using benchmark::DoNotOptimize;
|
||||||
|
|
|
@ -31,6 +31,9 @@ string GlobMatcher::Glob2Regex(string_view glob) {
|
||||||
in_group = 0;
|
in_group = 0;
|
||||||
}
|
}
|
||||||
regex.push_back(c);
|
regex.push_back(c);
|
||||||
|
if (c == '\\') {
|
||||||
|
regex.push_back(c); // escape it.
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue