commit: 321a131c20d83b0a7061c2b4600c4d77dec5b7fe
parent 3a507ba9b2fde594950a09c9d7934d54561a187c
Author: HJ <30-hj@users.noreply.git.pleroma.social>
Date: Tue, 6 Jun 2023 16:32:22 +0000
Merge branch 'cherry-pick-624af7ed' into 'master'
cherrypick parser fix into stable
See merge request pleroma/pleroma-fe!1836
Diffstat:
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/changelog.d/parser.fix b/changelog.d/parser.fix
@@ -0,0 +1 @@
+fix regex issue in HTML parser/renderer
diff --git a/src/components/rich_content/rich_content.jsx b/src/components/rich_content/rich_content.jsx
@@ -149,7 +149,9 @@ export default {
// Handle tag nodes
if (Array.isArray(item)) {
const [opener, children, closer] = item
- const Tag = getTagName(opener)
+ let Tag = getTagName(opener)
+ if (Tag.toLowerCase() === 'script') Tag = 'js-exploit'
+ if (Tag.toLowerCase() === 'style') Tag = 'css-exploit'
const fullAttrs = getAttrs(opener, () => true)
const attrs = getAttrs(opener)
const previouslyMentions = currentMentions !== null
diff --git a/src/services/html_converter/utility.service.js b/src/services/html_converter/utility.service.js
@@ -5,7 +5,7 @@
* @return {String} - tagname, i.e. "div"
*/
export const getTagName = (tag) => {
- const result = /(?:<\/(\w+)>|<(\w+)\s?.*?\/?>)/gi.exec(tag)
+ const result = /(?:<\/(\w+)>|<(\w+)\s?.*?\/?>)/gis.exec(tag)
return result && (result[1] || result[2])
}