From d1731fb01df5bc1f035c95df85688fea8a0d8487 Mon Sep 17 00:00:00 2001 From: slonkazoid Date: Thu, 30 Jan 2025 20:09:19 +0300 Subject: [PATCH] update dependencies and fix bug (thanks jorian) --- Cargo.lock | 297 ++++++++++++++++++++----------------- Cargo.toml | 15 +- src/app.rs | 3 +- src/config.rs | 2 +- src/error.rs | 19 ++- src/main.rs | 1 + src/markdown_render.rs | 10 +- src/path.rs | 43 ++++++ src/post/blag.rs | 2 +- src/post/markdown_posts.rs | 2 +- src/post/mod.rs | 2 +- templates/error.html | 3 +- 12 files changed, 244 insertions(+), 155 deletions(-) create mode 100644 src/path.rs diff --git a/Cargo.lock b/Cargo.lock index 71fa93d..276d976 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -57,17 +57,6 @@ dependencies = [ "askama_escape", ] -[[package]] -name = "askama_axum" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a41603f7cdbf5ac4af60760f17253eb6adf6ec5b6f14a7ed830cf687d375f163" -dependencies = [ - "askama", - "axum-core", - "http", -] - [[package]] name = "askama_derive" version = "0.12.5" @@ -134,9 +123,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.83" +version = "0.1.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" +checksum = "3f934833b4b7233644e5848f235df3f57ed8c80f1528a26c3dfa13d2147fa056" dependencies = [ "proc-macro2", "quote", @@ -153,7 +142,7 @@ dependencies = [ "derive_builder", "diligent-date-parser", "never", - "quick-xml 0.37.1", + "quick-xml 0.37.2", ] [[package]] @@ -175,9 +164,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" dependencies = [ "async-trait", - "axum-core", + "axum-core 0.4.5", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "itoa", + "matchit 0.7.3", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper", + "tower 0.5.2", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d6fd624c75e18b3b4c6b9caf42b1afe24437daaee904069137d8bab077be8b8" +dependencies = [ + "axum-core 0.5.0", "axum-macros", "bytes", + "form_urlencoded", "futures-util", "http", "http-body", @@ -185,7 +201,7 @@ dependencies = [ "hyper", "hyper-util", "itoa", - "matchit", + "matchit 0.8.4", "memchr", "mime", "percent-encoding", @@ -221,14 +237,33 @@ dependencies = [ "sync_wrapper", "tower-layer", "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df1362f362fd16024ae199c1970ce98f9661bf5ef94b9808fee734bc3698b733" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper", + "tower-layer", + "tower-service", "tracing", ] [[package]] name = "axum-macros" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d123550fa8d071b7255cb0cc04dc302baa6c8c4a79f55701552684d8399bce" +checksum = "604fde5e028fea851ce1d8570bbdc034bec850d157f7569d10f347d06808c05c" dependencies = [ "proc-macro2", "quote", @@ -277,8 +312,8 @@ version = "0.1.0" dependencies = [ "arc-swap", "askama", - "askama_axum", - "axum", + "async-trait", + "axum 0.8.1", "bitcode", "chrono", "color-eyre", @@ -289,7 +324,7 @@ dependencies = [ "futures", "handlebars", "include_dir", - "indexmap 2.7.0", + "indexmap 2.7.1", "mime_guess", "notify-debouncer-full", "rss", @@ -298,7 +333,7 @@ dependencies = [ "serde-value", "serde_json", "syntect", - "thiserror 2.0.9", + "thiserror 2.0.11", "tokio", "tokio-util", "toml", @@ -343,9 +378,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.6.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" [[package]] name = "block-buffer" @@ -358,9 +393,9 @@ dependencies = [ [[package]] name = "bon" -version = "3.3.1" +version = "3.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61030e4aaccae9727cc388843dcc7ad1fb9e1ccdef5571e3e8393976b49b74ce" +checksum = "fe7acc34ff59877422326db7d6f2d845a582b16396b6b08194942bf34c6528ab" dependencies = [ "bon-macros", "rustversion", @@ -368,9 +403,9 @@ dependencies = [ [[package]] name = "bon-macros" -version = "3.3.1" +version = "3.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67d5d25cc9bd33120702000acc60836db15f06eabc4466230bf79dc80bd0a6ee" +checksum = "4159dd617a7fbc9be6a692fe69dc2954f8e6bb6bb5e4d7578467441390d77fd0" dependencies = [ "darling", "ident_case", @@ -383,9 +418,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.16.0" +version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" [[package]] name = "bytemuck" @@ -407,19 +442,18 @@ checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" [[package]] name = "caseless" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808dab3318747be122cb31d36de18d4d1c81277a76f8332a02b81a3d73463d7f" +checksum = "8b6fd507454086c8edfd769ca6ada439193cdb209c7681712ef6275cccbfe5d8" dependencies = [ - "regex", "unicode-normalization", ] [[package]] name = "cc" -version = "1.2.6" +version = "1.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d6dbb628b8f8555f86d0323c2eb39e3ec81901f4b83e091db8a6a76d316a333" +checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229" dependencies = [ "jobserver", "libc", @@ -471,16 +505,14 @@ dependencies = [ [[package]] name = "comrak" -version = "0.32.0" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48ae8f3e7e3f3d424cbb33354fc36943d507327d210aa5794b0192f4be726c6d" +checksum = "52602e10393cfaaf8accaf707f2da743dc22cbe700a343ff8dbc9e5e04bc6b74" dependencies = [ "bon", "caseless", "entities", "memchr", - "once_cell", - "regex", "slug", "syntect", "typed-arena", @@ -528,15 +560,15 @@ dependencies = [ [[package]] name = "const-str" -version = "0.5.7" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3618cccc083bb987a415d85c02ca6c9994ea5b44731ec28b9ecf09658655fba9" +checksum = "671927c085eb5827d30b95df08f6c6a2301eafe2274c368bb2c16f42e03547eb" [[package]] name = "cpufeatures" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" dependencies = [ "libc", ] @@ -761,7 +793,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", - "miniz_oxide 0.8.2", + "miniz_oxide 0.8.3", ] [[package]] @@ -926,7 +958,7 @@ dependencies = [ "futures-core", "futures-sink", "http", - "indexmap 2.7.0", + "indexmap 2.7.1", "slab", "tokio", "tokio-util", @@ -935,17 +967,18 @@ dependencies = [ [[package]] name = "handlebars" -version = "6.2.0" +version = "6.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd4ccde012831f9a071a637b0d4e31df31c0f6c525784b35ae76a9ac6bc1e315" +checksum = "3d6b224b95c1e668ac0270325ad563b2eef1469fbbb8959bc7c692c844b813d9" dependencies = [ + "derive_builder", "log", "num-order", "pest", "pest_derive", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.11", ] [[package]] @@ -1015,9 +1048,9 @@ checksum = "9171a2ea8a68358193d15dd5d70c1c10a2afc3e7e4c5bc92bc9f025cebd7359c" [[package]] name = "httparse" -version = "1.9.5" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" +checksum = "f2d708df4e7140240a16cd6ab0ab65c972d7433ab77819ea693fde9c43811e2a" [[package]] name = "httpdate" @@ -1033,9 +1066,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "1.5.2" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" +checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" dependencies = [ "bytes", "futures-channel", @@ -1266,9 +1299,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.7.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" +checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" dependencies = [ "equivalent", "hashbrown 0.15.2", @@ -1277,11 +1310,11 @@ dependencies = [ [[package]] name = "inotify" -version = "0.10.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdd168d97690d0b8c412d6b6c10360277f4d7ee495c5d0d5d5fe0854923255cc" +checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.8.0", "inotify-sys", "libc", ] @@ -1295,15 +1328,6 @@ dependencies = [ "libc", ] -[[package]] -name = "instant" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" -dependencies = [ - "cfg-if", -] - [[package]] name = "itertools" version = "0.13.0" @@ -1366,7 +1390,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "libc", "redox_syscall", ] @@ -1385,9 +1409,9 @@ checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" [[package]] name = "log" -version = "0.4.22" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" [[package]] name = "matchers" @@ -1404,6 +1428,12 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" +[[package]] +name = "matchit" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" + [[package]] name = "memchr" version = "2.7.4" @@ -1443,9 +1473,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" +checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" dependencies = [ "adler2", ] @@ -1480,11 +1510,11 @@ dependencies = [ [[package]] name = "notify" -version = "7.0.0" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c533b4c39709f9ba5005d8002048266593c1cfaf3c5f0739d5b8ab0c6c504009" +checksum = "2fee8403b3d66ac7b26aee6e40a897d85dc5ce26f44da36b8b73e987cc52e943" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "filetime", "fsevent-sys", "inotify", @@ -1494,14 +1524,14 @@ dependencies = [ "mio", "notify-types", "walkdir", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "notify-debouncer-full" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dcf855483228259b2353f89e99df35fc639b2b2510d1166e4858e3f67ec1afb" +checksum = "d2d88b1a7538054351c8258338df7c931a590513fb3745e8c15eb9ff4199b8d1" dependencies = [ "file-id", "log", @@ -1512,12 +1542,9 @@ dependencies = [ [[package]] name = "notify-types" -version = "1.0.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585d3cb5e12e01aed9e8a1f70d5c6b5e86fe2a6e48fc8cd0b3e0b8df6f6eb174" -dependencies = [ - "instant", -] +checksum = "5e0826a989adedc2a244799e823aece04662b66609d96af8dff7ac6df9a8925d" [[package]] name = "nu-ansi-term" @@ -1630,7 +1657,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b7cafe60d6cf8e62e1b9b2ea516a089c008945bb5a275416789e7db0bc199dc" dependencies = [ "memchr", - "thiserror 2.0.9", + "thiserror 2.0.11", "ucd-trie", ] @@ -1670,18 +1697,18 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be57f64e946e500c8ee36ef6331845d40a93055567ec57e8fae13efd33759b95" +checksum = "1e2ec53ad785f4d35dac0adea7f7dc6f1bb277ad84a680c7afefeae05d1f5916" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" +checksum = "d56a66c0c55993aa927429d0f8a0abfd74f084e4d9c192cffed01e418d83eefb" dependencies = [ "proc-macro2", "quote", @@ -1690,9 +1717,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" @@ -1713,7 +1740,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42cf17e9a1800f5f396bc67d193dc9411b59012a5876445ef450d449881e1016" dependencies = [ "base64 0.22.1", - "indexmap 2.7.0", + "indexmap 2.7.1", "quick-xml 0.32.0", "serde", "time", @@ -1736,9 +1763,9 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.25" +version = "0.2.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" +checksum = "6924ced06e1f7dfe3fa48d57b9f74f55d8915f5036121bef647ef4b204895fac" dependencies = [ "proc-macro2", "syn", @@ -1746,9 +1773,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.92" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] @@ -1796,9 +1823,9 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.37.1" +version = "0.37.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f22f29bdff3987b4d8632ef95fd6424ec7e4e0a57e2f4fc63e489e75357f6a03" +checksum = "165859e9e55f79d67b96c5d96f4e88b6f2695a1972849c15a6a3f5c59fc2c003" dependencies = [ "encoding_rs", "memchr", @@ -1849,7 +1876,7 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", ] [[package]] @@ -1905,7 +1932,7 @@ dependencies = [ "atom_syndication", "derive_builder", "never", - "quick-xml 0.37.1", + "quick-xml 0.37.2", ] [[package]] @@ -1922,9 +1949,9 @@ checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" [[package]] name = "ryu" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" [[package]] name = "same-file" @@ -1983,11 +2010,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.134" +version = "1.0.138" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d" +checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" dependencies = [ - "indexmap 2.7.0", + "indexmap 2.7.1", "itoa", "memchr", "ryu", @@ -2121,9 +2148,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.92" +version = "2.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ae51629bf965c5c098cc9e87908a3df5301051a9e087d6f9bef5c9771ed126" +checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" dependencies = [ "proc-macro2", "quote", @@ -2181,11 +2208,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.9" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f072643fd0190df67a8bab670c20ef5d8737177d6ac6b2e9a236cb096206b2cc" +checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" dependencies = [ - "thiserror-impl 2.0.9", + "thiserror-impl 2.0.11", ] [[package]] @@ -2201,9 +2228,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.9" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b50fa271071aae2e6ee85f842e2e28ba8cd2c5fb67f11fcb1fd70b276f9e7d4" +checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" dependencies = [ "proc-macro2", "quote", @@ -2278,9 +2305,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.42.0" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" +checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" dependencies = [ "backtrace", "bytes", @@ -2296,9 +2323,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", @@ -2356,7 +2383,7 @@ version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ - "indexmap 2.7.0", + "indexmap 2.7.1", "serde", "serde_spanned", "toml_datetime", @@ -2371,7 +2398,7 @@ checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" dependencies = [ "async-stream", "async-trait", - "axum", + "axum 0.7.9", "base64 0.22.1", "bytes", "h2", @@ -2435,7 +2462,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "403fa3b783d4b626a8ad51d766ab03cb6d2dbfc46b1c5d4448395e6628dc9697" dependencies = [ "async-compression", - "bitflags 2.6.0", + "bitflags 2.8.0", "bytes", "futures-core", "futures-util", @@ -2570,9 +2597,9 @@ checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539" [[package]] name = "unicode-ident" -version = "1.0.14" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" [[package]] name = "unicode-normalization" @@ -2615,9 +2642,9 @@ checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" [[package]] name = "valuable" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" [[package]] name = "version_check" @@ -2652,20 +2679,21 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", "once_cell", + "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", @@ -2677,9 +2705,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2687,9 +2715,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", @@ -2700,9 +2728,12 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] [[package]] name = "winapi" @@ -2819,9 +2850,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.20" +version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +checksum = "ad699df48212c6cc6eb4435f35500ac6fd3b9913324f938aea302022ce19d310" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 235365e..7806031 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,11 +16,9 @@ strip = true [dependencies] arc-swap = { version = "1.7.1", features = ["serde"] } -askama = { version = "0.12.1", features = [ - "with-axum", -], default-features = false } -askama_axum = { version = "0.4.0", default-features = false } -axum = { version = "0.7.5", features = [ +askama = { version = "0.12.1", default-features = false } +async-trait = "0.1.85" +axum = { version = "0.8.1", features = [ "http1", "json", "query", @@ -34,18 +32,19 @@ chrono = { version = "0.4.37", features = [ "serde", ], default-features = false } color-eyre = "0.6.3" -comrak = { version = "0.32.0", features = [ +comrak = { version = "0.35.0", features = [ "syntect", + "bon", ], default-features = false } console-subscriber = { version = "0.4.1", optional = true } -const-str = "0.5.7" +const-str = "0.6.0" fronma = "0.2.0" futures = "0.3.31" handlebars = "6.0.0" include_dir = "0.7.4" indexmap = { version = "2.7.0", features = ["serde"] } mime_guess = "2.0.5" -notify-debouncer-full = { version = "0.4.0", default-features = false } +notify-debouncer-full = { version = "0.5.0", default-features = false } rss = "2.0.7" scc = { version = "2.1.0", features = ["serde"] } serde = { version = "1.0.197", features = ["derive", "rc"] } diff --git a/src/app.rs b/src/app.rs index 8e9fb59..cfbdd5a 100644 --- a/src/app.rs +++ b/src/app.rs @@ -22,6 +22,7 @@ use tracing::{info, info_span, Span}; use crate::config::{DirsConfig, RssConfig, StyleConfig}; use crate::error::{AppError, AppResult}; +use crate::path::SafePath; use crate::post::{Filter, PostManager, PostMetadata, RenderStats, ReturnedPost}; use crate::serve_dir_included::handle; @@ -281,7 +282,7 @@ async fn post( templates, .. }): State, - Path(name): Path>, + SafePath(name): SafePath>, Query(query): Query, ) -> AppResult { match posts.get_post(name.clone(), &query.other).await? { diff --git a/src/config.rs b/src/config.rs index 04ebc0d..54bfa73 100644 --- a/src/config.rs +++ b/src/config.rs @@ -359,7 +359,7 @@ pub async fn watcher( .parent() .expect("absolute path to have parent"); debouncer - .watch(&dir, RecursiveMode::NonRecursive) + .watch(dir, RecursiveMode::NonRecursive) .with_context(|| format!("failed to watch {dir:?}"))?; 'event_loop: while let Some(ev) = select! { diff --git a/src/error.rs b/src/error.rs index 07f295d..d684bc5 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,8 +1,8 @@ use std::sync::Arc; -use askama_axum::Template; +use askama::Template; use axum::http::StatusCode; -use axum::response::{IntoResponse, Response}; +use axum::response::{Html, IntoResponse, Response}; use color_eyre::eyre; use thiserror::Error; use tracing::error; @@ -46,7 +46,7 @@ impl From for PostError { } impl IntoResponse for PostError { - fn into_response(self) -> axum::response::Response { + fn into_response(self) -> Response { (StatusCode::INTERNAL_SERVER_ERROR, self.to_string()).into_response() } } @@ -88,6 +88,17 @@ impl IntoResponse for AppError { AppError::RssDisabled => StatusCode::FORBIDDEN, _ => StatusCode::INTERNAL_SERVER_ERROR, }; - (status_code, ErrorTemplate { error }).into_response() + + match (ErrorTemplate { error }.render()) { + Ok(rendered) => (status_code, Html(rendered)).into_response(), + Err(err) => { + error!("error while rendering error template: {err}"); + ( + StatusCode::INTERNAL_SERVER_ERROR, + "error while trying to show error. good job", + ) + .into_response() + } + } } } diff --git a/src/main.rs b/src/main.rs index a8b7162..d10fabe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,7 @@ mod de; mod error; mod helpers; mod markdown_render; +mod path; mod platform; mod post; mod serve_dir_included; diff --git a/src/markdown_render.rs b/src/markdown_render.rs index 415bedd..3cafb41 100644 --- a/src/markdown_render.rs +++ b/src/markdown_render.rs @@ -1,9 +1,9 @@ use color_eyre::eyre::{self, Context}; use comrak::adapters::SyntaxHighlighterAdapter; -use comrak::markdown_to_html_with_plugins; use comrak::plugins::syntect::{SyntectAdapter, SyntectAdapterBuilder}; use comrak::ComrakOptions; use comrak::RenderPlugins; +use comrak::{markdown_to_html_with_plugins, Plugins}; use syntect::highlighting::ThemeSet; use crate::config::MarkdownRenderConfig; @@ -42,10 +42,12 @@ pub fn render( options.render.escape = config.escape; options.render.unsafe_ = config.unsafe_; - let mut render_plugins = RenderPlugins::default(); - render_plugins.codefence_syntax_highlighter = syntect; + let render_plugins = RenderPlugins { + codefence_syntax_highlighter: syntect, + ..Default::default() + }; - let plugins = comrak::Plugins::builder().render(render_plugins).build(); + let plugins = Plugins::builder().render(render_plugins).build(); markdown_to_html_with_plugins(markdown, &options, &plugins) } diff --git a/src/path.rs b/src/path.rs new file mode 100644 index 0000000..bd7de1c --- /dev/null +++ b/src/path.rs @@ -0,0 +1,43 @@ +use axum::extract::rejection::PathRejection; +use axum::extract::{FromRequestParts, Path}; +use axum::http::request::Parts; +use axum::http::StatusCode; +use axum::response::{IntoResponse, Response}; +use serde::de::DeserializeOwned; +use thiserror::Error; + +pub struct SafePath(pub T); + +impl FromRequestParts for SafePath +where + T: DeserializeOwned, + T: AsRef, + T: Send + Sync, + S: Send + Sync, +{ + type Rejection = SafePathRejection; + + async fn from_request_parts(parts: &mut Parts, state: &S) -> Result { + let s = Path::::from_request_parts(parts, state).await?.0; + + if s.as_ref().contains("..") || s.as_ref().contains('/') { + return Err(SafePathRejection::Test); + } + + Ok(SafePath(s)) + } +} + +#[derive(Error, Debug)] +pub enum SafePathRejection { + #[error("test")] + Test, + #[error(transparent)] + PathRejection(#[from] PathRejection), +} + +impl IntoResponse for SafePathRejection { + fn into_response(self) -> Response { + (StatusCode::BAD_REQUEST, self.to_string()).into_response() + } +} diff --git a/src/post/blag.rs b/src/post/blag.rs index ba1a692..505aaa0 100644 --- a/src/post/blag.rs +++ b/src/post/blag.rs @@ -6,7 +6,7 @@ use std::sync::Arc; use std::time::Duration; use arc_swap::access::Access; -use axum::async_trait; +use async_trait::async_trait; use axum::http::HeaderValue; use chrono::{DateTime, Utc}; use futures::stream::FuturesUnordered; diff --git a/src/post/markdown_posts.rs b/src/post/markdown_posts.rs index cd3e073..7963cb5 100644 --- a/src/post/markdown_posts.rs +++ b/src/post/markdown_posts.rs @@ -8,7 +8,7 @@ use std::time::Instant; use std::time::SystemTime; use arc_swap::access::Access; -use axum::async_trait; +use async_trait::async_trait; use axum::http::HeaderValue; use chrono::{DateTime, Utc}; use color_eyre::eyre::{self, Context}; diff --git a/src/post/mod.rs b/src/post/mod.rs index ce453e6..6a3c193 100644 --- a/src/post/mod.rs +++ b/src/post/mod.rs @@ -5,7 +5,7 @@ pub mod markdown_posts; use std::sync::Arc; use std::time::Duration; -use axum::async_trait; +use async_trait::async_trait; use axum::http::HeaderValue; use chrono::{DateTime, Utc}; use indexmap::IndexMap; diff --git a/templates/error.html b/templates/error.html index 6e1bdea..521ec67 100644 --- a/templates/error.html +++ b/templates/error.html @@ -5,8 +5,9 @@ error + - +

error

{{ error }}