Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update regex for striptags method to prevent regex dos #349

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jwestbrook
Copy link
Collaborator

Per conversation, here is the Pull Request for the advisory. Attempt 2

@erik-krogh
Copy link

👍

codemasher added a commit to codemasher/prototype that referenced this pull request Mar 2, 2021
@jwestbrook jwestbrook mentioned this pull request Jan 14, 2022
@madrobby
Copy link
Collaborator

madrobby commented Jan 14, 2022

Heya, is there a test somewhere demonstrating that this works? Thanks.

Ideally, this should be added to master/test/unit/tests/string.test.js

@elhennig
Copy link

Is there any plan to create a new release including this fix?

@Nikunj-daga-94
Copy link

Nikunj-daga-94 commented Apr 22, 2022

This RegEx does not seem to work i tried in my project MY unit tests are failing since the UI id being created using this are incorrect/changed. Any ideas?

@madhusudhanreddyvade
Copy link

Try below

function stripTags() {
return this.replace(/<(?=(\w+))\1(\s+("[^"]"|'[^']'|[^>])+)?>|</(?=(\w+))\1>/gi, '');
}

@AyushRawat1996
Copy link

Can anyone please update on this PR?

@savetheclocktower
Copy link
Collaborator

The project is not active and will not be doing further releases. You are encouraged to apply this fix yourself after loading prototype.js:

String.prototype.stripTags = function () {
  return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>'"])+)?\s*("[^">]*|'[^'>])?(\/)?>|<\/\w+>/gi, '');
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants