mirror of
https://github.com/axllent/mailpit.git
synced 2026-04-18 12:09:30 +00:00
Security: Escape ContentID in HTML replacement to prevent regex injection
This commit is contained in:
@@ -151,8 +151,9 @@ export default {
|
||||
for (const i in d.Inline) {
|
||||
const a = d.Inline[i];
|
||||
if (a.ContentID !== "") {
|
||||
const escapedCID = a.ContentID.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
d.HTML = d.HTML.replace(
|
||||
new RegExp("(=[\"']?)(cid:" + a.ContentID + ")([\"|'|\\s|\\/|>|;])", "g"),
|
||||
new RegExp("(=[\"']?)(cid:" + escapedCID + ")([\"'|\\s|\\/|>|;])", "g"),
|
||||
"$1" + this.resolve("/api/v1/message/" + d.ID + "/part/" + a.PartID) + "$3",
|
||||
);
|
||||
}
|
||||
@@ -171,8 +172,9 @@ export default {
|
||||
for (const i in d.Attachments) {
|
||||
const a = d.Attachments[i];
|
||||
if (a.ContentID !== "") {
|
||||
const escapedCID = a.ContentID.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
d.HTML = d.HTML.replace(
|
||||
new RegExp("(=[\"']?)(cid:" + a.ContentID + ")([\"|'|\\s|\\/|>|;])", "g"),
|
||||
new RegExp("(=[\"']?)(cid:" + escapedCID + ")([\"'|\\s|\\/|>|;])", "g"),
|
||||
"$1" + this.resolve("/api/v1/message/" + d.ID + "/part/" + a.PartID) + "$3",
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user