Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion GUI/src/services/service-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,12 @@

const spacePlaceholder = '___SPACE___';
const rawMessage = typeof parentNode.data.message === 'string' ? decodeHtmlEntities(parentNode.data.message) : '';
const rawMessageWithSpaceholders = rawMessage
.replaceAll('{{', '${')
.replaceAll('}}', '}')
.replaceAll(/(<[^>]+>)|( )/g, (_match, tag) => (tag === undefined ? spacePlaceholder : tag));

Check failure on line 757 in GUI/src/services/service-builder.ts

View workflow job for this annotation

GitHub Actions / frontend-lint / run-check

Make sure the regex used here, which is vulnerable to super-linear runtime due to backtracking, cannot lead to denial of service
const markdownMessage = htmlToMarkdown
.translate(rawMessage.replace('{{', '${').replace('}}', '}').replaceAll(' ', spacePlaceholder))
.translate(rawMessageWithSpaceholders)
.replaceAll(spacePlaceholder, ' ')
.replaceAll(/\\([-~>[\]_*#().!`=<\\])/g, String.raw`\\$1`);

Expand Down
Loading