about summary refs log tree commit diff stats
path: root/src/main.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-12-05 20:20:07 +0100
committerbptato <nincsnevem662@gmail.com>2024-12-05 20:20:07 +0100
commita3dc167925f7255b35c11f8c7e6607fb6e0d6b52 (patch)
tree814c57ce0d864c019ba670e19d29324aebeea673 /src/main.nim
parent03dae38fdf2e7d9da912701e851a5d0684947d58 (diff)
downloadchawan-a3dc167925f7255b35c11f8c7e6607fb6e0d6b52.tar.gz
mimetypes: refactor, use mime.types for inline image extensions
* remove std/streams use from mime.types; mmap and parse directly
* use mime.types for inline image extensions
* add some jpeg file extensions

Latter came up because I was trying to add a format locally and it
wouldn't recognize it on images from my file system (i.e. by extension).

As a security measure we still do not allow additional extensions for
predefined inline image types.
Diffstat (limited to 'src/main.nim')
-rw-r--r--src/main.nim2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/main.nim b/src/main.nim
index 3a1c8daa..3c88ccf2 100644
--- a/src/main.nim
+++ b/src/main.nim
@@ -220,10 +220,12 @@ proc initConfig(ctx: ParamParseContext; config: Config;
     if (let ps = newPosixStream(getCurrentDir() / "res/config.toml");
         ps != nil):
       ?config.parseConfig(getCurrentDir(), ps.recvAll(), warnings)
+      ps.sclose()
   if ps != nil:
     let src = ps.recvDataLoopOrMmap()
     ?config.parseConfig(config.dir, src.toOpenArray(), warnings)
     deallocMem(src)
+    ps.sclose()
   for opt in ctx.opts:
     ?config.parseConfig(getCurrentDir(), opt, warnings, laxnames = true)
   config.css.stylesheet &= ctx.stylesheet