Skip to content

Commit 97f358d

Browse files
committed
Fix relative paths causing issues with attachments
Signed-off-by: Michael Haeuslmann <michael.haeuslmann@gmail.com>
1 parent f7265be commit 97f358d

File tree

2 files changed

+66
-24
lines changed

2 files changed

+66
-24
lines changed

CHANGELOG.md

+62-22
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,122 @@
11
# Changelog
2+
23
All notable changes to this project will be documented in this file.
34

45
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
56
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
67

78
## [Unreleased]
89

10+
## [0.14.1] - 2021-08-25
11+
12+
### Fixed
13+
14+
- Fixed relative parts in attachments causing issues. Now `../../example.png` will be flattened to `___example.png`.
15+
916
## [0.14.0] - 2021-03-05
17+
1018
### Added
11-
- Support for rendering `<details>` blocks [as Confluence expand macros](https://confluence.atlassian.com/doc/expand-macro-223222352.html)
19+
20+
- Support for rendering `<details>` blocks [as Confluence expand macros](https://confluence.atlassian.com/doc/expand-macro-223222352.html)
1221

1322
## [0.13.3] - 2021-02-10
23+
1424
## [0.13.2] - 2021-02-10
25+
1526
### Fixed
16-
- Upgrade dependencies in order to fix vulnerabilities
17-
- Write self-closing tags for Confluence compatibility (e.g. `<hr />`)
27+
28+
- Upgrade dependencies in order to fix vulnerabilities
29+
- Write self-closing tags for Confluence compatibility (e.g. `<hr />`)
1830

1931
## [0.13.1] - 2020-07-06
32+
2033
### Fixed
21-
- Moved jest and prettier to dev dependencies
34+
35+
- Moved jest and prettier to dev dependencies
2236

2337
## [0.13.0] - 2020-07-04
38+
2439
### Fixed
25-
- Added retry for a weird confluence bug where the first attempt would result in a 501 response, and the second one works
40+
41+
- Added retry for a weird confluence bug where the first attempt would result in a 501 response, and the second one works
2642

2743
## [0.12.3] - 2019-12-27
44+
2845
### Fixed
29-
- Bug where error was thrown if not language was supplied for language block
46+
47+
- Bug where error was thrown if not language was supplied for language block
3048

3149
## [0.12.2] - 2019-12-23
50+
3251
### Fixed
33-
- Print proper URL after successful upload
52+
53+
- Print proper URL after successful upload
3454

3555
## [0.12.1] - 2019-12-23
56+
3657
### Fixed
37-
- Do not use newline for extracted title (fixes [#1](https://github.com/mihaeu/cosmere/issues/1))
58+
59+
- Do not use newline for extracted title (fixes [#1](https://github.com/mihaeu/cosmere/issues/1))
3860

3961
## [0.12.0] - 2019-12-23
62+
4063
### Added
41-
- Print link to confluence page after successful upload
64+
65+
- Print link to confluence page after successful upload
4266

4367
### Fixed
44-
- Set highlighting for known languages
45-
- Use only first line of title
46-
- Remote diff
68+
69+
- Set highlighting for known languages
70+
- Use only first line of title
71+
- Remote diff
4772

4873
## [0.11.0] - 2019-12-20
74+
4975
### Changed
50-
- renaming to cosmere, all binaries, config entries etc. changed
76+
77+
- renaming to cosmere, all binaries, config entries etc. changed
5178

5279
# [0.10.0] - 2019-12-18
80+
5381
### Changed
54-
- `pageTitle` config item is now optional if a level one header is found in the corresponding document. If neither is available an error is thrown.
82+
83+
- `pageTitle` config item is now optional if a level one header is found in the corresponding document. If neither is available an error is thrown.
5584

5685
## [0.9.0] - 2019-12-07
86+
5787
### Fixed
58-
- Convert to storage representation directly instead of view to upload strings without encoding
59-
- Always load markdown files relative to the config file
88+
89+
- Convert to storage representation directly instead of view to upload strings without encoding
90+
- Always load markdown files relative to the config file
6091

6192
## [0.8.1] - 2019-12-03
93+
6294
### Fixed
63-
- Attachment upload
95+
96+
- Attachment upload
6497

6598
## [0.8.0] - 2019-12-03
99+
66100
### Added
67-
- This changelog file
101+
102+
- This changelog file
68103

69104
### Changed
70-
- Update remote version only if there's an actual change
105+
106+
- Update remote version only if there's an actual change
71107

72108
### Fixed
73-
- Attachment upload
109+
110+
- Attachment upload
74111

75112
## [0.7.0] - 2019-12-02
113+
76114
### Changed
77-
- Add backward compatibility for node 8 (`fs.mkdir`)
78115

79-
[Unreleased]: https://github.com/mihaeu/cosmere/compare/0.14.0...HEAD
116+
- Add backward compatibility for node 8 (`fs.mkdir`)
117+
118+
[unreleased]: https://github.com/mihaeu/cosmere/compare/0.14.1...HEAD
119+
[0.14.1]: https://github.com/mihaeu/cosmere/compare/0.14.0...0.14.1
80120
[0.14.0]: https://github.com/mihaeu/cosmere/compare/0.13.3...0.14.0
81121
[0.13.3]: https://github.com/mihaeu/cosmere/compare/0.13.2...0.13.3
82122
[0.13.2]: https://github.com/mihaeu/cosmere/compare/0.13.1...0.13.2

src/UpdatePage.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,16 @@ async function updateAttachments(mdWikiData: string, pageData: Page, cachePath:
8787
signale.error(`Attachment "${attachment}" not found.`);
8888
});
8989
for (const attachment of attachments) {
90-
const newFilename = cachePath + "/" + attachment.replace("/..", "_").replace("/", "_");
90+
const newFilename = cachePath + "/" + attachment.replace(/(\.\.|\/)/g, "_");
9191
const absoluteAttachmentPath = path.resolve(path.dirname(pageData.file), attachment);
9292
fs.copyFileSync(absoluteAttachmentPath, newFilename);
9393

9494
signale.await(`Uploading attachment "${attachment}" for "${pageData.title}" ...`);
9595
await confluenceAPI.uploadAttachment(newFilename, pageData.pageId);
9696
}
97-
mdWikiData = mdWikiData.replace(/<ri:attachment ri:filename=".+?"/g, (s: string) => s.replace("/", "_"));
97+
mdWikiData = mdWikiData.replace(/<ri:attachment ri:filename=".+?"/g, (s: string) =>
98+
s.replace(/(\.\.|\/)/g, "_"),
99+
);
98100
}
99101
return mdWikiData;
100102
}

0 commit comments

Comments
 (0)