feat(security): strip XSSI prefix from XHR responses.
This commit is contained in:
@@ -273,6 +273,29 @@ export function main() {
|
||||
existingXHRs[0].dispatchEvent('load');
|
||||
}));
|
||||
|
||||
it('should strip XSSI prefixes', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var conn = new XHRConnection(sampleRequest, new MockBrowserXHR(), new ResponseOptions());
|
||||
conn.response.subscribe((res: Response) => {
|
||||
expect(res.text()).toBe('{json: "object"}');
|
||||
async.done();
|
||||
});
|
||||
existingXHRs[0].setStatusCode(200);
|
||||
existingXHRs[0].setResponseText(')]}\',\n{json: "object"}');
|
||||
existingXHRs[0].dispatchEvent('load');
|
||||
}));
|
||||
|
||||
it('should strip XSSI prefix from errors', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var conn =
|
||||
new XHRConnection(sampleRequest, new MockBrowserXHR(), new ResponseOptions());
|
||||
conn.response.subscribe(null, (res: Response) => {
|
||||
expect(res.text()).toBe('{json: "object"}');
|
||||
async.done();
|
||||
});
|
||||
existingXHRs[0].setStatusCode(404);
|
||||
existingXHRs[0].setResponseText(')]}\',\n{json: "object"}');
|
||||
existingXHRs[0].dispatchEvent('load');
|
||||
}));
|
||||
|
||||
it('should parse response headers and add them to the response',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var statusCode = 200;
|
||||
|
||||
Reference in New Issue
Block a user