diff options
author | Chocobozzz <me@florianbigard.com> | 2020-06-26 16:01:04 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-06-26 16:08:53 +0200 |
commit | cc0e0d32ea7f65475630bcdee1f1fa8a8c71eb05 (patch) | |
tree | 1628ade33a809056c8f755fe83c5e167f46f28ec /client/src/app/core/rest/rest.service.ts | |
parent | d8b382912e82a535c8158ee496fe396a84851b4e (diff) | |
download | PeerTube-cc0e0d32ea7f65475630bcdee1f1fa8a8c71eb05.tar.gz PeerTube-cc0e0d32ea7f65475630bcdee1f1fa8a8c71eb05.tar.zst PeerTube-cc0e0d32ea7f65475630bcdee1f1fa8a8c71eb05.zip |
Fix query string parsing
Diffstat (limited to 'client/src/app/core/rest/rest.service.ts')
-rw-r--r-- | client/src/app/core/rest/rest.service.ts | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/client/src/app/core/rest/rest.service.ts b/client/src/app/core/rest/rest.service.ts index 78558851a..c12b6bd41 100644 --- a/client/src/app/core/rest/rest.service.ts +++ b/client/src/app/core/rest/rest.service.ts | |||
@@ -68,8 +68,9 @@ export class RestService { | |||
68 | parseQueryStringFilter (q: string, prefixes: QueryStringFilterPrefixes): ParseQueryStringFilterResult { | 68 | parseQueryStringFilter (q: string, prefixes: QueryStringFilterPrefixes): ParseQueryStringFilterResult { |
69 | if (!q) return {} | 69 | if (!q) return {} |
70 | 70 | ||
71 | // Tokenize the strings using spaces | 71 | // Tokenize the strings using spaces that are not in quotes |
72 | const tokens = q.split(' ').filter(token => !!token) | 72 | const tokens = q.match(/(?:[^\s"]+|"[^"]*")+/g) |
73 | .filter(token => !!token) | ||
73 | 74 | ||
74 | // Build prefix array | 75 | // Build prefix array |
75 | const prefixeStrings = Object.values(prefixes) | 76 | const prefixeStrings = Object.values(prefixes) |
@@ -88,6 +89,7 @@ export class RestService { | |||
88 | 89 | ||
89 | const matchedTokens = tokens.filter(t => t.startsWith(prefix)) | 90 | const matchedTokens = tokens.filter(t => t.startsWith(prefix)) |
90 | .map(t => t.slice(prefix.length)) // Keep the value filter | 91 | .map(t => t.slice(prefix.length)) // Keep the value filter |
92 | .map(t => t.replace(/^"|"$/g, '')) | ||
91 | .map(t => { | 93 | .map(t => { |
92 | if (prefixObj.handler) return prefixObj.handler(t) | 94 | if (prefixObj.handler) return prefixObj.handler(t) |
93 | 95 | ||