From c056ddf42211ec3186e82a3c6ec04ec9666d8f72 Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Thu, 23 Mar 2023 09:30:45 +0000 Subject: [PATCH] fix(routes/pdf/txt): limit charsets to poppler supported ones only --- src/routes/pdf/txt/schema.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/routes/pdf/txt/schema.js b/src/routes/pdf/txt/schema.js index f848c2c71..9e94346b4 100644 --- a/src/routes/pdf/txt/schema.js +++ b/src/routes/pdf/txt/schema.js @@ -107,7 +107,28 @@ const pdfToTxtPostSchema = { S.string() .default("UTF-8") .description("Sets the encoding to use for text output") - .pattern(/^[-\w]+$/m) + // Encodings supported by Poppler + .enum([ + "Big5", + "Big5ascii", + "EUC-CN", + "EUC-JP", + "GBK", + "ISO-2022-CN", + "ISO-2022-JP", + "ISO-2022-KR", + "ISO-8859-6", + "ISO-8859-7", + "ISO-8859-8", + "ISO-8859-9", + "KOI8-R", + "Latin2", + "Shift-JIS", + "TIS-620", + "UTF-8", + "UTF-16", + "Windows-1255", + ]) ) .prop( "ownerPassword",