diff --git a/debian/changelog b/debian/changelog index f386781..61b545c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +wb-rules (2.20.4) stable; urgency=medium + + * Remove restriction on rule file name + + -- Nikolay Korotkiy Mon, 09 Apr 2024 11:28:00 +0400 + wb-rules (2.20.3) stable; urgency=medium * Move wbgo.so plugin to /usr/lib, no functional changes diff --git a/wbrules/editor.go b/wbrules/editor.go index 962d372..0f54162 100644 --- a/wbrules/editor.go +++ b/wbrules/editor.go @@ -4,14 +4,11 @@ import ( "io/ioutil" "os" "path" - "regexp" "strings" "github.com/wirenboard/wbgong" ) -var editorPathRx = regexp.MustCompile(`^[\w /-]{0,256}[\w -]{1,253}\.js$`) - type Editor struct { locFileManager LocFileManager } @@ -44,7 +41,6 @@ const ( EDITOR_ERROR_INVALID_LEN = 1009 ) -var invalidPathError = &EditorError{EDITOR_ERROR_INVALID_PATH, "File path should contains only digits, letters, whitespaces, '_' and '-' chars"} var invalidExtensionError = &EditorError{EDITOR_ERROR_INVALID_EXT, "File name should ends with .js"} var invalidLenError = &EditorError{EDITOR_ERROR_INVALID_LEN, "File path should be shorter than or equal to 512 chars"} var listDirError = &EditorError{EDITOR_ERROR_LISTDIR, "Error listing the directory"} @@ -85,8 +81,6 @@ func (editor *Editor) Save(args *EditorSaveArgs, reply *EditorSaveResponse) erro return invalidExtensionError } else if len(args.Path) > 512 { return invalidLenError - } else if !editorPathRx.MatchString(pth) { - return invalidPathError } *reply = EditorSaveResponse{nil, pth, nil} diff --git a/wbrules/editor_test.go b/wbrules/editor_test.go index 5b75721..f99587b 100644 --- a/wbrules/editor_test.go +++ b/wbrules/editor_test.go @@ -248,10 +248,6 @@ func (s *EditorSuite) TestSaveFile() { "sub/sample6.js": "sample6 -- error", }) - s.VerifyRpcError("Save", objx.Map{"path": "../foo/bar.js", "content": "evilfile"}, - EDITOR_ERROR_INVALID_PATH, "EditorError", invalidPathError.Error()) - s.VerifyRpcError("Save", objx.Map{"path": "qqq/$$$rrr.js", "content": "lamefile"}, - EDITOR_ERROR_INVALID_PATH, "EditorError", invalidPathError.Error()) s.verifySources(map[string]string{ "sample1.js": "// sample1 (changed)", "sample2.js": "// sample2", diff --git a/wbrules/esengine.go b/wbrules/esengine.go index 8ff2df7..baa0ef7 100644 --- a/wbrules/esengine.go +++ b/wbrules/esengine.go @@ -889,7 +889,7 @@ func (engine *ESEngine) LiveWriteScript(virtualPath, content string) error { // LiveLoadFile for the file, but as the new content // will be already registered with the contentTracker, // duplicate reload will not happen - err = ioutil.WriteFile(cleanPath, []byte(content), 0777) + err = ioutil.WriteFile(cleanPath, []byte(content), 0644) if err != nil { r <- err return