Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

query cannot match to %0A #315

Closed
lukeng opened this issue Nov 9, 2017 · 2 comments
Closed

query cannot match to %0A #315

lukeng opened this issue Nov 9, 2017 · 2 comments
Labels

Comments

@lukeng
Copy link

lukeng commented Nov 9, 2017

The following test will be failed, no matter UseEncodedPath() is used or not.

func TestQuery(t *testing.T) {
	url := "http://localhost/test?q=%0A"

	hit := false
	m := mux.NewRouter()
	m.Path("/test").Queries("q", "{q}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		hit = true
	})

	req, _ := http.NewRequest("GET", url, nil)
	m.ServeHTTP(&httptest.ResponseRecorder{}, req)
	if !hit {
		t.Errorf("query did not hit")
	}
}

It looks like the defaultPattern in newRouteRegexp did not include the newline char.
I tried changing the value from ".*" to "(?s).*", then the test passes.

But I do not sure the fix is appropriate.

@highway900
Copy link

this is the same for {value} parameters see #77

@stale
Copy link

stale bot commented Dec 9, 2018

This issue has been automatically marked as stale because it hasn't seen a recent update. It'll be automatically closed in a few days.

@stale stale bot added the stale label Dec 9, 2018
@stale stale bot closed this as completed Dec 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants