Skip to content

Commit 9c64ddf

Browse files
committed
Escape XML characters in anchors
Closes #37
1 parent e4bcc5d commit 9c64ddf

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.17.2] - 2023-01-09
11+
12+
### Fixed
13+
14+
- Escape XML characters in anchors due to Confluence API validation errors
15+
1016
## [0.17.1] - 2023-01-09
1117

1218
### Fixed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cosmere",
3-
"version": "0.17.1",
3+
"version": "0.17.2",
44
"description": "Sync your markdown files to confluence.",
55
"main": "dist/index.js",
66
"bin": {

src/ConfluenceRenderer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default class ConfluenceRenderer extends Renderer<string> {
8686
if (href) {
8787
href = this.resolveLinks(href);
8888
}
89-
return super.link(href, title, text);
89+
return super.link(escapeXmlCharacters(href ?? ""), title, text);
9090
}
9191

9292
private resolveLinks(href: string): string {

tests/ConfluenceRenderer.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ describe("ConfluenceRenderer", () => {
138138
);
139139
});
140140

141+
it("renders links to websites and converts XML characters", () => {
142+
expect(confluenceRenderer.link("http://example.com?test=<>&'\"", "test", "nothing")).toBe(
143+
`<a href="http://example.com?test=&lt;&gt;&amp;&apos;&quot;" title="test">nothing</a>`,
144+
);
145+
});
146+
141147
it("renders links to other matching markdown files as Confluence links", () => {
142148
expect(confluenceRenderer.link("./other.md", "", "")).toBe(
143149
`<a href="https://my-confluence.com/pages/viewpage.action?pageId=456"></a>`,

0 commit comments

Comments
 (0)