Skip to content

Commit

Permalink
Use html sanitized text for attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
minottic committed Apr 18, 2024
1 parent 90fea3a commit fdfd91e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions sci-log-db/src/__tests__/unit/service.export-snippet.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,16 @@ describe('Export service unit', function (this: Suite) {
[['someFile.pdf', 'accessHash2']],
],
},
{
input: [
{files: [{fileHash: 'hash123', accessHash: 'accessHash2'}]},
'<div class="fileLink" href="file:hash123">someFile_>_.pdf</div>',
],
expected: [
'<filelink>attachments/someFile_&gt;_.pdf</filelink>',
[['someFile_>_.pdf', 'accessHash2']],
],
},
].forEach((t, i) => {
it(`attachment ${i}`, async () => {
const element = textContentToHTML({textcontent: t.input[1]} as Paragraph);
Expand Down
2 changes: 1 addition & 1 deletion sci-log-db/src/services/export-snippets.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export class ExportService {
`.fileLink[href='file:${fileSnippet.fileHash}']`,
);
if (!fileLinkElement) return;
const attachment = fileLinkElement.innerHTML;
const attachment = fileLinkElement.textContent ?? '';
const attachmentElement = this.document.createElement('fileLink');
attachmentElement.innerHTML = `${this.attachmentsFolder}/${fileLinkElement.innerHTML}`;
fileLinkElement.replaceWith(attachmentElement);
Expand Down

0 comments on commit fdfd91e

Please sign in to comment.