Skip to content

Commit 4813b25

Browse files
committed
wip
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent 706918d commit 4813b25

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/_helpers/mime.node.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ const MIMETYPE_TEXT_PLAIN: MimeType = 'text/plain'
2525

2626
const MAP_TEXT_EXTENSION_MIMETYPE: Readonly<Record<string, MimeType>> = {
2727
'': MIMETYPE_TEXT_PLAIN,
28-
// https://www.iana.org/assignments/media-types/media-types.xhtml#text
28+
// https://www.iana.org/assignments/media-types/media-types.xhtml
2929
'.csv': 'text/csv',
3030
'.htm': 'text/html',
3131
'.html': 'text/html',
3232
'.md': 'text/markdown',
3333
'.txt': MIMETYPE_TEXT_PLAIN,
3434
'.rst': 'text/prs.fallenstein.rst',
35-
'.rtf': 'text/rtf', // not `application/xml` -- our scope is text!
35+
'.rtf': 'application/rtf', // our scope is text, yes, but RTF is binary - so we should base64 encode it ...
3636
'.xml': 'text/xml', // not `application/xml` -- our scope is text!
3737
// add more mime types above this line. pull-requests welcome!
3838
// license-specific files

src/utils/licenseUtility.node.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ export class LicenseEvidenceGatherer<P extends string = string> {
8585
}
8686
try {
8787
yield { filePath, file, text: new Attachment(
88-
this.#fs.readFileSync(filePath).toString('base64'), // may throw
88+
// since we cannot be sure weather the file content is text-only, or maybe binary,
89+
// we tend to base64 everything, regardless of the detected encoding.
90+
this.#fs.readFileSync(filePath) // may throw
91+
.toString('base64'),
8992
{ contentType, encoding: AttachmentEncoding.Base64 }
9093
) }
9194
} catch (cause) {

0 commit comments

Comments
 (0)