Fix missing UnescapePath for a token
This commit is contained in:
parent
dc11d33a97
commit
90974fed30
@ -30,7 +30,9 @@ func TestUnmarshal(t *testing.T) {
|
||||
{":xxx", "", "xxx"},
|
||||
{"foo:xxx", "foo", "xxx"},
|
||||
{"foo::bar:xxx", "foo:bar", "xxx"},
|
||||
{"foo:::bar:xxx", "foo:", "bar:xxx"},
|
||||
{"foo::::bar:xxx", "foo::bar", "xxx"},
|
||||
{"foo-bar:%26%21%27", "foo-bar", "%26%21%27"},
|
||||
}
|
||||
|
||||
for _, d := range data {
|
||||
|
||||
15
rtmp/rtmp.go
15
rtmp/rtmp.go
@ -220,8 +220,21 @@ func GetToken(u *url.URL) (string, string) {
|
||||
return u.Path, ""
|
||||
}
|
||||
|
||||
rawPath := "/" + strings.Join(pathElements[:nPathElements-1], "/")
|
||||
rawToken := pathElements[nPathElements-1]
|
||||
|
||||
path, err := url.PathUnescape(rawPath)
|
||||
if err != nil {
|
||||
path = rawPath
|
||||
}
|
||||
|
||||
token, err := url.PathUnescape(rawToken)
|
||||
if err != nil {
|
||||
token = rawToken
|
||||
}
|
||||
|
||||
// Return the path without the token
|
||||
return "/" + strings.Join(pathElements[:nPathElements-1], "/"), pathElements[nPathElements-1]
|
||||
return path, token
|
||||
}
|
||||
|
||||
func splitPath(path string) []string {
|
||||
|
||||
@ -12,6 +12,8 @@ func TestToken(t *testing.T) {
|
||||
{"/foo/bar", "/foo", "bar"},
|
||||
{"/foo/bar?token=abc", "/foo/bar", "abc"},
|
||||
{"/foo/bar/abc", "/foo/bar", "abc"},
|
||||
{"/foo/bar/&!'", "/foo/bar", "&!'"},
|
||||
{"/foo/bar/%26%21%27", "/foo/bar", "&!'"},
|
||||
}
|
||||
|
||||
for _, d := range data {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user