fix(http): don't encode values that are allowed in query (#9651)

This implements a new class, QueryEncoder, that provides
methods for encoding keys and values of query parameter.
The encoder encodes with encodeURIComponent, and then
decodes a whitelist of allowed characters back to their
unencoded form.

BREAKING CHANGE:

The changes to Http's URLSearchParams serialization now 
prevent encoding of these characters inside query parameters
which were previously converted to percent-encoded values:

@ : $ , ; + ; ? /

The default encoding behavior can be overridden by extending
QueryEncoder, as documented in the URLSearchParams service.

Fixes #9348
This commit is contained in:
Jeff Cross
2016-06-28 11:31:35 -07:00
committed by GitHub
parent bf598d6b8b
commit 1620426393
4 changed files with 108 additions and 6 deletions

View File

@ -100,6 +100,12 @@ export declare abstract class JSONPConnection implements Connection {
abstract finished(data?: any): void;
}
/** @experimental */
export declare class QueryEncoder {
encodeKey(k: string): string;
encodeValue(v: string): string;
}
/** @experimental */
export declare enum ReadyState {
Unsent = 0,
@ -209,7 +215,7 @@ export declare enum ResponseType {
export declare class URLSearchParams {
paramsMap: Map<string, string[]>;
rawParams: string;
constructor(rawParams?: string);
constructor(rawParams?: string, queryEncoder?: QueryEncoder);
append(param: string, val: string): void;
appendAll(searchParams: URLSearchParams): void;
clone(): URLSearchParams;