mirror of
https://github.com/kovetskiy/mark.git
synced 2025-04-24 05:42:40 +08:00
fix 305: external images URLs are not properly escaped
This commit is contained in:
parent
622be6e25f
commit
eba2396010
@ -482,6 +482,9 @@ func (r *ConfluenceRenderer) renderImage(writer util.BufWriter, source []byte, n
|
||||
|
||||
// We were unable to resolve it locally, treat as URL
|
||||
if err != nil {
|
||||
escapedURL := string(n.Destination)
|
||||
escapedURL = strings.ReplaceAll(escapedURL, "&", "&")
|
||||
|
||||
err = r.Stdlib.Templates.ExecuteTemplate(
|
||||
writer,
|
||||
"ac:image",
|
||||
@ -498,7 +501,7 @@ func (r *ConfluenceRenderer) renderImage(writer util.BufWriter, source []byte, n
|
||||
string(n.Title),
|
||||
string(nodeToHTMLText(n, source)),
|
||||
"",
|
||||
string(n.Destination),
|
||||
escapedURL,
|
||||
},
|
||||
)
|
||||
} else {
|
||||
|
2
pkg/mark/testdata/links.html
vendored
2
pkg/mark/testdata/links.html
vendored
@ -5,7 +5,7 @@
|
||||
<p>Use <ac:link><ri:page ri:content-title="Another Page"/><ac:plain-text-link-body><![CDATA[Another Page]]></ac:plain-text-link-body></ac:link></p>
|
||||
<p>Use <ac:link><ri:page ri:content-title="Page With Space"/><ac:plain-text-link-body><![CDATA[page link with spaces]]></ac:plain-text-link-body></ac:link></p>
|
||||
<p><ac:image ac:alt="My Image"><ri:attachment ri:filename="test.png"/></ac:image></p>
|
||||
<p><ac:image ac:alt="My External Image"><ri:url ri:value="http://confluence.atlassian.com/images/logo/confluence_48_trans.png"/></ac:image></p>
|
||||
<p><ac:image ac:alt="My External Image"><ri:url ri:value="http://confluence.atlassian.com/images/logo/confluence_48_trans.png?key1=value1&key2=value2"/></ac:image></p>
|
||||
<p>Use footnotes link <sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup></p>
|
||||
<div class="footnotes" role="doc-endnotes">
|
||||
<hr />
|
||||
|
2
pkg/mark/testdata/links.md
vendored
2
pkg/mark/testdata/links.md
vendored
@ -12,7 +12,7 @@ Use [page link with spaces](<ac:Page With Space>)
|
||||
|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
Use footnotes link [^1]
|
||||
[^1]: a footnote link
|
||||
|
Loading…
x
Reference in New Issue
Block a user