Fix query string parsing
authorChocobozzz <me@florianbigard.com>
Fri, 26 Jun 2020 14:01:04 +0000 (16:01 +0200)
committerChocobozzz <me@florianbigard.com>
Fri, 26 Jun 2020 14:08:53 +0000 (16:08 +0200)
client/src/app/+admin/moderation/video-abuse-list/video-abuse-details.component.html
client/src/app/core/rest/rest.service.ts

index 5512bb1dea80f7f77e7dfbd091ef32df52035991..ec808cdb823faa4b1bc4127facc73b2f23cbb25b 100644 (file)
@@ -17,7 +17,7 @@
             <span class="text-muted">{{ videoAbuse.reporterAccount.nameWithHost }}</span>
           </div>
         </a>
-        <a [routerLink]="[ '/admin/moderation/video-abuses/list' ]" [queryParams]="{ 'search': 'reportee:&quot;' + videoAbuse.reporterAccount.displayName + '&quot;' }" class="ml-auto text-muted video-details-links" i18n>
+        <a [routerLink]="[ '/admin/moderation/video-abuses/list' ]" [queryParams]="{ 'search': 'reporter:&quot;' + videoAbuse.reporterAccount.displayName + '&quot;' }" class="ml-auto text-muted video-details-links" i18n>
           {videoAbuse.countReportsForReporter, plural, =1 {1 report} other {{{ videoAbuse.countReportsForReporter }} reports}}<span class="ml-1 glyphicon glyphicon-flag"></span>
         </a>
       </span>
@@ -90,4 +90,4 @@
       <div *ngIf="!videoAbuse.video.deleted && !videoAbuse.video.blacklisted" [innerHTML]="videoAbuse.embedHtml"></div>
     </div>
   </div>
-</div>
\ No newline at end of file
+</div>
index 78558851a79fff2d3c6e4d95c41f205d1f3ef0fd..c12b6bd41c22849a06263a2a6bbd18498c572328 100644 (file)
@@ -68,8 +68,9 @@ export class RestService {
   parseQueryStringFilter (q: string, prefixes: QueryStringFilterPrefixes): ParseQueryStringFilterResult {
     if (!q) return {}
 
-    // Tokenize the strings using spaces
-    const tokens = q.split(' ').filter(token => !!token)
+    // Tokenize the strings using spaces that are not in quotes
+    const tokens = q.match(/(?:[^\s"]+|"[^"]*")+/g)
+                    .filter(token => !!token)
 
     // Build prefix array
     const prefixeStrings = Object.values(prefixes)
@@ -88,6 +89,7 @@ export class RestService {
 
       const matchedTokens = tokens.filter(t => t.startsWith(prefix))
                                   .map(t => t.slice(prefix.length)) // Keep the value filter
+                                  .map(t => t.replace(/^"|"$/g, ''))
                                   .map(t => {
                                     if (prefixObj.handler) return prefixObj.handler(t)