Merge pull request #3545 from DSpace/backport-3481-to-dspace-7_x

[Port dspace-7_x] Fix code scanning alert no. 6: Incomplete string escaping or encoding
This commit is contained in:
Tim Donohue
2024-10-23 14:33:08 -05:00
committed by GitHub

View File

@@ -157,7 +157,7 @@ export class Metadata {
const outputKeys: string[] = [];
for (const inputKey of inputKeys) {
if (inputKey.includes('*')) {
const inputKeyRegex = new RegExp('^' + inputKey.replace(/\./g, '\\.').replace(/\*/g, '.*') + '$');
const inputKeyRegex = new RegExp('^' + inputKey.replace(/\\/g, '\\\\').replace(/\./g, '\\.').replace(/\*/g, '.*') + '$');
for (const mapKey of Object.keys(mdMap)) {
if (!outputKeys.includes(mapKey) && inputKeyRegex.test(mapKey)) {
outputKeys.push(mapKey);