Skip to content

Commit

Permalink
fix(): Fix security issue on regular expression (#5019)
Browse files Browse the repository at this point in the history
  • Loading branch information
aamalric-talend authored Nov 29, 2023
1 parent 795a12e commit c508840
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/nice-schools-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/react-cmf': minor
---

fix(): Fix security issue on regular expression
1 change: 1 addition & 0 deletions packages/cmf/__tests__/settings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ describe('settings', () => {
describe('withoutHOC', () => {
it('should remove all HOC prefix', () => {
expect(withoutHOC('Connect(CMF(Container(MyComponent)))')).toBe('MyComponent');
expect(withoutHOC('Connect(CMF(Container(Comp_+*[]~-=@{})))')).toBe('Comp_+*[]~-=@{}');
});
});
});
5 changes: 3 additions & 2 deletions packages/cmf/src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ export function generateDefaultViewId(viewId, componentName, componentId) {

/**
* Extract component name without HOC
* @param {String} viewId Connect(CMF(Container(MyComponent)))
* @param {String} componentName Connect(CMF(Container(MyComponent)))
* @return {String} MyComponent
*/
export function withoutHOC(componentName) {
return componentName.match(/.*\((.*?)\)/)[1];
const parts = componentName.split('(');
return parts[parts.length - 1].replaceAll(')', '');
}

/**
Expand Down

0 comments on commit c508840

Please sign in to comment.