From de19148754158145a6dce8f9e0ac392a126bccae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Wed, 22 Apr 2020 15:33:50 +0200 Subject: [PATCH] [33115] Escape uriComponent in members autocompleter https://community.openproject.com/wp/33115 --- .../members/members-autocompleter.component.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/modules/members/members-autocompleter.component.ts b/frontend/src/app/modules/members/members-autocompleter.component.ts index 3a90ec92ea..0773d3ba56 100644 --- a/frontend/src/app/modules/members/members-autocompleter.component.ts +++ b/frontend/src/app/modules/members/members-autocompleter.component.ts @@ -2,8 +2,9 @@ import {UserAutocompleterComponent} from "core-app/modules/common/autocomplete/u import {Observable} from "rxjs"; import {map} from "rxjs/operators"; import {InjectField} from "core-app/helpers/angular/inject-field.decorator"; -import {HttpClient} from "@angular/common/http"; +import {HttpClient, HttpParams} from "@angular/common/http"; import {Component} from "@angular/core"; +import {URLParamsEncoder} from "core-app/modules/hal/services/url-params-encoder"; export const membersAutocompleterSelector = 'members-autocompleter'; @@ -14,13 +15,15 @@ export const membersAutocompleterSelector = 'members-autocompleter'; export class MembersAutocompleterComponent extends UserAutocompleterComponent { @InjectField() http:HttpClient; - protected getAvailableUsers(url:string, searchTerm:any):Observable<{[key:string]:string|null}[]> { + protected getAvailableUsers(url:string, searchTerm:any):Observable<{ [key:string]:string|null }[]> { return this.http .get(url, - { params: { q: searchTerm }, + { + params: new HttpParams({ encoder: new URLParamsEncoder(), fromObject: { q: searchTerm } }), responseType: 'json', - headers: { 'Content-Type': 'application/json; charset=utf-8' }}, - ) + headers: { 'Content-Type': 'application/json; charset=utf-8' } + }, + ) .pipe( map((res:any) => { return res.results.items.map((el:any) => {