Skip to content

Update regex for striptags method to prevent regex dos - #349

Open
jwestbrook wants to merge 2 commits into
prototypejs:masterfrom
jwestbrook:advisory-JAN-2021
Open

Update regex for striptags method to prevent regex dos#349
jwestbrook wants to merge 2 commits into
prototypejs:masterfrom
jwestbrook:advisory-JAN-2021

Conversation

@jwestbrook

Copy link
Copy Markdown
Collaborator

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

@erik-krogh

Copy link
Copy Markdown

👍

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

madrobby commented Jan 14, 2022

Copy link
Copy Markdown
Collaborator

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
Copy Markdown

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

@Nikunj-daga-94

Nikunj-daga-94 commented Apr 22, 2022

Copy link
Copy Markdown

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
Copy Markdown

Try below

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

@AyushRawat1996

Copy link
Copy Markdown

Can anyone please update on this PR?

@savetheclocktower

Copy link
Copy Markdown
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, '');
};
jesusbagpuss added a commit to jesusbagpuss/eprints3.4 that referenced this pull request Feb 19, 2025
Prototype isn't maintained, but the CVE can be resolved.
Taken from:
prototypejs/prototype#349
drn05r pushed a commit to eprints/eprints3.4 that referenced this pull request Mar 6, 2025
* Update 20_prototype.js for CVE-2020-27511

Prototype isn't maintained, but the CVE can be resolved.
Taken from:
prototypejs/prototype#349

* Update 20_prototype.js

Change Version string

* Make mis-matched single-quotes greedier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

8 participants