mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge pull request #1060 from atmire/w2p-77215_lgtm-issues-and-sanitization
Fix or address string escaping / replacement issues reported by LGTM
This commit is contained in:
@@ -102,7 +102,7 @@ export class AuthInterceptor implements HttpInterceptor {
|
||||
private parseLocation(header: string): string {
|
||||
let location = header.trim();
|
||||
location = location.replace('location="', '');
|
||||
location = location.replace('"', '');
|
||||
location = location.replace('"', ''); /* lgtm [js/incomplete-sanitization] */
|
||||
let re = /%3A%2F%2F/g;
|
||||
location = location.replace(re, '://');
|
||||
re = /%3A/g;
|
||||
|
@@ -20,6 +20,7 @@ const dcTitle0 = mdValue('Title 0');
|
||||
const dcTitle1 = mdValue('Title 1');
|
||||
const dcTitle2 = mdValue('Title 2', 'en_US');
|
||||
const bar = mdValue('Bar');
|
||||
const test = mdValue('Test');
|
||||
|
||||
const singleMap = { 'dc.title': [dcTitle0] };
|
||||
|
||||
@@ -30,6 +31,11 @@ const multiMap = {
|
||||
'foo': [bar]
|
||||
};
|
||||
|
||||
const regexTestMap = {
|
||||
'foolbar.baz': [test],
|
||||
'foo.bard': [test],
|
||||
};
|
||||
|
||||
const multiViewModelList = [
|
||||
{ key: 'dc.description', ...dcDescription, order: 0 },
|
||||
{ key: 'dc.description.abstract', ...dcAbstract, order: 0 },
|
||||
@@ -98,6 +104,9 @@ describe('Metadata', () => {
|
||||
testAll([multiMap, singleMap], 'dc.*', [dcDescription, dcAbstract, dcTitle1, dcTitle2]);
|
||||
testAll([multiMap, singleMap], ['dc.title', 'dc.*'], [dcTitle1, dcTitle2, dcDescription, dcAbstract]);
|
||||
});
|
||||
describe('with regexTestMap', () => {
|
||||
testAll(regexTestMap, 'foo.bar.*', []);
|
||||
});
|
||||
});
|
||||
|
||||
describe('allValues method', () => {
|
||||
|
@@ -156,7 +156,7 @@ export class Metadata {
|
||||
const outputKeys: string[] = [];
|
||||
for (const inputKey of inputKeys) {
|
||||
if (inputKey.includes('*')) {
|
||||
const inputKeyRegex = new RegExp('^' + inputKey.replace('.', '\.').replace('*', '.*') + '$');
|
||||
const inputKeyRegex = new RegExp('^' + inputKey.replace(/\./g, '\\.').replace(/\*/g, '.*') + '$');
|
||||
for (const mapKey of Object.keys(mdMap)) {
|
||||
if (!outputKeys.includes(mapKey) && inputKeyRegex.test(mapKey)) {
|
||||
outputKeys.push(mapKey);
|
||||
|
Reference in New Issue
Block a user