diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2022-06-19 19:56:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-19 12:56:22 +0100 |
commit | 05a74e6e22984d31c61f38b1174882cf19b1f81c (patch) | |
tree | 289315f99a5410a87fb6be39e515602b1925ef15 /modules/git/git.go | |
parent | cc42c6488a818499e363935c214d5c4d0aaff554 (diff) | |
download | gitea-05a74e6e22984d31c61f38b1174882cf19b1f81c.tar.gz gitea-05a74e6e22984d31c61f38b1174882cf19b1f81c.zip |
use quoted regexp instead of git fixed-value (#20029)
Diffstat (limited to 'modules/git/git.go')
-rw-r--r-- | modules/git/git.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/modules/git/git.go b/modules/git/git.go index 3a3663995b..0652a75f9a 100644 --- a/modules/git/git.go +++ b/modules/git/git.go @@ -11,6 +11,7 @@ import ( "fmt" "os" "os/exec" + "regexp" "runtime" "strings" "sync" @@ -337,7 +338,7 @@ func configSetNonExist(key, value string) error { } func configAddNonExist(key, value string) error { - _, _, err := NewCommand(DefaultContext, "config", "--fixed-value", "--get", key, value).RunStdString(nil) + _, _, err := NewCommand(DefaultContext, "config", "--get", key, regexp.QuoteMeta(value)).RunStdString(nil) if err == nil { // already exist return nil @@ -357,7 +358,7 @@ func configUnsetAll(key, value string) error { _, _, err := NewCommand(DefaultContext, "config", "--get", key).RunStdString(nil) if err == nil { // exist, need to remove - _, _, err = NewCommand(DefaultContext, "config", "--global", "--fixed-value", "--unset-all", key, value).RunStdString(nil) + _, _, err = NewCommand(DefaultContext, "config", "--global", "--unset-all", key, regexp.QuoteMeta(value)).RunStdString(nil) if err != nil { return fmt.Errorf("failed to unset git global config %s, err: %w", key, err) } |