-
Notifications
You must be signed in to change notification settings - Fork 219
Fix ReDoS in stripHtml #308
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,8 +3,8 @@ const entities = require('entities'); | |
| const xml2js = require('xml2js'); | ||
|
|
||
| utils.stripHtml = function(str) { | ||
| str = str.replace(/([^\n])<\/?(h|br|p|ul|ol|li|blockquote|section|table|tr|div)(?:.|\n)*?>([^\n])/gm, '$1\n$3') | ||
| str = str.replace(/<(?:.|\n)*?>/gm, ''); | ||
| str = str.replace(/([^\n])<\/?(h|br|p|ul|ol|li|blockquote|section|table|tr|div)[^<>]*>([^\n])/gm, '$1\n$3') | ||
| str = str.replace(/<[^<>]*>/gm, ''); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Behavior change: a literal Measured with the old vs. new bodies of A literal Concretely: add a case to the (If you ever want the old semantics back without the ReDoS, |
||
| return str; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.