From 1c1fcd3fd7ca299912be35c1dbda375a53b33ac6 Mon Sep 17 00:00:00 2001 From: Andrew Leschinsky Date: Wed, 30 Oct 2019 16:47:46 -0400 Subject: [PATCH] `safeDecodeURIComponent` on the server side Without this fix, getting 'URIError: URI malformed' if cookie value cannot be decoded, for example '%' (a single percentage sign) --- src/server/server-cookies.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/server-cookies.service.ts b/src/server/server-cookies.service.ts index 9a28554..4ea3d72 100644 --- a/src/server/server-cookies.service.ts +++ b/src/server/server-cookies.service.ts @@ -2,7 +2,7 @@ import { Inject, Injectable } from '@angular/core'; import { CookiesOptions } from '../cookies-options'; import { CookiesOptionsService } from '../cookies-options.service'; import { CookiesService } from '../cookies.service'; -import { isString, mergeOptions } from '../utils'; +import { isString, mergeOptions, safeDecodeURIComponent } from '../utils'; @Injectable() export class ServerCookiesService extends CookiesService { @@ -24,7 +24,7 @@ export class ServerCookiesService extends CookiesService { const cookies: { [key: string]: any } = {}; for (const name in allCookies) { if (typeof allCookies[name] !== 'undefined') { - cookies[name] = decodeURIComponent(allCookies[name]); + cookies[name] = safeDecodeURIComponent(allCookies[name]); } } return cookies;