1
0
mirror of https://github.com/axllent/mailpit.git synced 2025-08-15 20:13:16 +02:00

UI: Remove <base /> tag if set in HTML preview

This commit is contained in:
Ralph Slooten
2023-07-16 00:16:45 +12:00
parent aeb3585f3e
commit be3979241f
2 changed files with 7 additions and 6 deletions

View File

@@ -190,6 +190,11 @@ export default {
this.resizeIframe(el)
},
sanitizeHTML: function (h) {
// remove <base/> tag if set
return h.replace(/<base .*>/mi, '')
},
saveTags: function () {
let self = this
@@ -370,7 +375,7 @@ export default {
<div v-if="message.HTML != ''" class="tab-pane fade show" id="nav-html" role="tabpanel"
aria-labelledby="nav-html-tab" tabindex="0">
<div id="responsive-view" :class="scaleHTMLPreview" :style="responsiveSizes[scaleHTMLPreview]">
<iframe target-blank="" class="tab-pane d-block" id="preview-html" :srcdoc="message.HTML"
<iframe target-blank="" class="tab-pane d-block" id="preview-html" :srcdoc="sanitizeHTML(message.HTML)"
v-on:load="resizeIframe" frameborder="0" style="width: 100%; height: 100%;">
</iframe>
</div>

View File

@@ -13,7 +13,6 @@ import (
"os/signal"
"path"
"path/filepath"
"regexp"
"sort"
"strings"
"syscall"
@@ -540,10 +539,7 @@ func GetMessage(id string) (*Message, error) {
Text: env.Text,
}
// strip base tags
var re = regexp.MustCompile(`(?U)<base .*>`)
html := re.ReplaceAllString(env.HTML, "")
obj.HTML = html
obj.HTML = env.HTML
obj.Inline = []Attachment{}
obj.Attachments = []Attachment{}