Skip to content

Commit

Permalink
fix(proxy): fix qfile query parsing
Browse files Browse the repository at this point in the history
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
  • Loading branch information
gfanton committed Feb 7, 2025
1 parent b48447e commit aa992df
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions contribs/gnodev/pkg/proxy/path_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"log/slog"
"net"
"net/http"
"net/url"
"path/filepath"
"strings"
"sync"

Expand Down Expand Up @@ -312,11 +312,14 @@ func handleQuery(path string, data []byte, upaths uniqPaths) error {

case "vm/qrender", "vm/qfile", "vm/qfuncs", "vm/qeval":
path, _, _ := strings.Cut(string(data), ":") // Cut arguments out
u, err := url.Parse(path)
if err != nil {
return fmt.Errorf("unable to parse path: %w", err)
path = filepath.Clean(path)

// If path is a file, grab the directory instead
if ext := filepath.Ext(path); ext != "" {
path = filepath.Dir(path)
}

Check warning on line 320 in contribs/gnodev/pkg/proxy/path_interceptor.go

View check run for this annotation

Codecov / codecov/patch

contribs/gnodev/pkg/proxy/path_interceptor.go#L320

Added line #L320 was not covered by tests
upaths.add(strings.TrimSpace(u.Path))

upaths.add(path)
return nil

default:
Expand Down

0 comments on commit aa992df

Please sign in to comment.