diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b1a96784..bb4c5ad1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,12 @@ jobs: run: cargo clippy --all-targets --manifest-path=c-api/Cargo.toml --target-dir=target - name: Run clippy on JS API run: cargo clippy --all-targets --manifest-path=js-api/Cargo.toml --target-dir=target - + - name: Check semver + uses: obi1kenobi/cargo-semver-checks-action@v2 + with: + package: lol_html + feature-group: default-features + verbose: true test: name: Test runs-on: ubuntu-latest diff --git a/Cargo.toml b/Cargo.toml index a4dc5cdc..3c1b3c25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lol_html" -version = "2.1.0" +version = "2.2.0" authors = ["Ivan Nikulin "] license = "BSD-3-Clause" description = "Streaming HTML rewriter/parser with CSS selector-based API" @@ -11,6 +11,7 @@ keywords = ["html", "css-selectors", "parser", "rewriter", "streaming"] readme = "README.md" include = ["/Cargo.toml", "/LICENSE", "/README.md", "/media", "/src"] edition = "2021" +rust-version = "1.80" [lib] # Disable libtest to make sure criterion can parse the command line flags. @@ -50,7 +51,7 @@ serde_derive = "1.0.19" serde_json = "1.0.65" static_assertions = "1.1.0" rand = "0.8.5" -itertools = "0.13" +itertools = "0.14" [lints.rust] keyword_idents = { level = "deny", priority = 1 } diff --git a/c-api/Cargo.lock b/c-api/Cargo.lock index 739cd374..954418c9 100644 --- a/c-api/Cargo.lock +++ b/c-api/Cargo.lock @@ -4,9 +4,9 @@ version = 4 [[package]] name = "allocator-api2" -version = "0.2.18" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "bitflags" @@ -48,7 +48,7 @@ dependencies = [ "dtoa-short", "itoa", "matches", - "phf", + "phf 0.10.1", "proc-macro2", "quote", "smallvec", @@ -62,7 +62,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" dependencies = [ "quote", - "syn 2.0.87", + "syn 2.0.94", ] [[package]] @@ -75,7 +75,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.87", + "syn 2.0.94", ] [[package]] @@ -110,9 +110,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "foldhash" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" +checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" [[package]] name = "fxhash" @@ -131,14 +131,25 @@ checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] name = "hashbrown" -version = "0.15.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ "allocator-api2", "equivalent", @@ -153,9 +164,9 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "libc" -version = "0.2.161" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "log" @@ -165,7 +176,7 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "lol_html" -version = "2.1.0" +version = "2.2.0" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -217,9 +228,18 @@ name = "phf" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" +dependencies = [ + "phf_shared 0.8.0", +] + +[[package]] +name = "phf" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" dependencies = [ "phf_macros", - "phf_shared", + "phf_shared 0.10.0", "proc-macro-hack", ] @@ -229,8 +249,8 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbffee61585b0411840d3ece935cce9cb6321f01c45477d30066498cd5e1a815" dependencies = [ - "phf_generator", - "phf_shared", + "phf_generator 0.8.0", + "phf_shared 0.8.0", ] [[package]] @@ -239,18 +259,28 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" dependencies = [ - "phf_shared", - "rand", + "phf_shared 0.8.0", + "rand 0.7.3", +] + +[[package]] +name = "phf_generator" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" +dependencies = [ + "phf_shared 0.10.0", + "rand 0.8.5", ] [[package]] name = "phf_macros" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6fde18ff429ffc8fe78e2bf7f8b7a5a5a6e2a8b58bc5a9ac69198bbda9189c" +checksum = "58fdf3184dd560f160dd73922bea2d5cd6e8f064bf4b13110abd81b03697b4e0" dependencies = [ - "phf_generator", - "phf_shared", + "phf_generator 0.10.0", + "phf_shared 0.10.0", "proc-macro-hack", "proc-macro2", "quote", @@ -266,6 +296,15 @@ dependencies = [ "siphasher", ] +[[package]] +name = "phf_shared" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +dependencies = [ + "siphasher", +] + [[package]] name = "ppv-lite86" version = "0.2.20" @@ -289,18 +328,18 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] @@ -311,14 +350,25 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "getrandom", + "getrandom 0.1.16", "libc", - "rand_chacha", - "rand_core", + "rand_chacha 0.2.2", + "rand_core 0.5.1", "rand_hc", "rand_pcg", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + [[package]] name = "rand_chacha" version = "0.2.2" @@ -326,7 +376,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", ] [[package]] @@ -335,7 +395,16 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom", + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.15", ] [[package]] @@ -344,7 +413,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "rand_core", + "rand_core 0.5.1", ] [[package]] @@ -353,7 +422,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" dependencies = [ - "rand_core", + "rand_core 0.5.1", ] [[package]] @@ -376,7 +445,7 @@ dependencies = [ "derive_more", "fxhash", "log", - "phf", + "phf 0.8.0", "phf_codegen", "precomputed-hash", "servo_arc", @@ -385,9 +454,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.23" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +checksum = "3cb6eb87a131f756572d7fb904f6e7b68633f09cca868c5df1c4b8d1a694bbba" [[package]] name = "servo_arc" @@ -430,9 +499,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.87" +version = "2.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "987bc0be1cdea8b10216bd06e2ca407d40b9543468fafd3ddfb02f36e77f71f3" dependencies = [ "proc-macro2", "quote", @@ -441,29 +510,29 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.4" +version = "2.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f49a1853cf82743e3b7950f77e0f4d622ca36cf4317cba00c767838bac8d490" +checksum = "f072643fd0190df67a8bab670c20ef5d8737177d6ac6b2e9a236cb096206b2cc" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.4" +version = "2.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8381894bb3efe0c4acac3ded651301ceee58a15d47c2e34885ed1908ad667061" +checksum = "7b50fa271071aae2e6ee85f842e2e28ba8cd2c5fb67f11fcb1fd70b276f9e7d4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.94", ] [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "wasi" @@ -471,6 +540,12 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "zerocopy" version = "0.7.35" @@ -489,5 +564,5 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.94", ] diff --git a/js-api/Cargo.lock b/js-api/Cargo.lock index 520c9b34..0e8013bb 100644 --- a/js-api/Cargo.lock +++ b/js-api/Cargo.lock @@ -54,7 +54,7 @@ dependencies = [ "dtoa-short", "itoa", "matches", - "phf", + "phf 0.10.1", "proc-macro2", "quote", "smallvec", @@ -68,7 +68,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" dependencies = [ "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -81,7 +81,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -116,9 +116,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "foldhash" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" +checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" [[package]] name = "fxhash" @@ -137,14 +137,25 @@ checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] name = "hashbrown" -version = "0.15.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ "allocator-api2", "equivalent", @@ -159,9 +170,9 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "js-sys" -version = "0.3.74" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a865e038f7f6ed956f788f0d7d60c541fff74c7bd74272c5d4cf15c63743e705" +checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" dependencies = [ "once_cell", "wasm-bindgen", @@ -169,9 +180,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.167" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "log" @@ -194,7 +205,7 @@ dependencies = [ [[package]] name = "lol_html" -version = "2.1.0" +version = "2.2.0" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -242,9 +253,18 @@ name = "phf" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" +dependencies = [ + "phf_shared 0.8.0", +] + +[[package]] +name = "phf" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" dependencies = [ "phf_macros", - "phf_shared", + "phf_shared 0.10.0", "proc-macro-hack", ] @@ -254,8 +274,8 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbffee61585b0411840d3ece935cce9cb6321f01c45477d30066498cd5e1a815" dependencies = [ - "phf_generator", - "phf_shared", + "phf_generator 0.8.0", + "phf_shared 0.8.0", ] [[package]] @@ -264,18 +284,28 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" dependencies = [ - "phf_shared", - "rand", + "phf_shared 0.8.0", + "rand 0.7.3", +] + +[[package]] +name = "phf_generator" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" +dependencies = [ + "phf_shared 0.10.0", + "rand 0.8.5", ] [[package]] name = "phf_macros" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6fde18ff429ffc8fe78e2bf7f8b7a5a5a6e2a8b58bc5a9ac69198bbda9189c" +checksum = "58fdf3184dd560f160dd73922bea2d5cd6e8f064bf4b13110abd81b03697b4e0" dependencies = [ - "phf_generator", - "phf_shared", + "phf_generator 0.10.0", + "phf_shared 0.10.0", "proc-macro-hack", "proc-macro2", "quote", @@ -291,6 +321,15 @@ dependencies = [ "siphasher", ] +[[package]] +name = "phf_shared" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +dependencies = [ + "siphasher", +] + [[package]] name = "ppv-lite86" version = "0.2.20" @@ -323,9 +362,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] @@ -336,14 +375,25 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "getrandom", + "getrandom 0.1.16", "libc", - "rand_chacha", - "rand_core", + "rand_chacha 0.2.2", + "rand_core 0.5.1", "rand_hc", "rand_pcg", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + [[package]] name = "rand_chacha" version = "0.2.2" @@ -351,7 +401,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", ] [[package]] @@ -360,7 +420,16 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom", + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.15", ] [[package]] @@ -369,7 +438,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "rand_core", + "rand_core 0.5.1", ] [[package]] @@ -378,7 +447,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" dependencies = [ - "rand_core", + "rand_core 0.5.1", ] [[package]] @@ -401,7 +470,7 @@ dependencies = [ "derive_more", "fxhash", "log", - "phf", + "phf 0.8.0", "phf_codegen", "precomputed-hash", "servo_arc", @@ -410,15 +479,15 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.23" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +checksum = "3cb6eb87a131f756572d7fb904f6e7b68633f09cca868c5df1c4b8d1a694bbba" [[package]] name = "serde" -version = "1.0.215" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] @@ -436,13 +505,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.215" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -486,9 +555,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.90" +version = "2.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" +checksum = "987bc0be1cdea8b10216bd06e2ca407d40b9543468fafd3ddfb02f36e77f71f3" dependencies = [ "proc-macro2", "quote", @@ -497,22 +566,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.4" +version = "2.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f49a1853cf82743e3b7950f77e0f4d622ca36cf4317cba00c767838bac8d490" +checksum = "f072643fd0190df67a8bab670c20ef5d8737177d6ac6b2e9a236cb096206b2cc" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.4" +version = "2.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8381894bb3efe0c4acac3ded651301ceee58a15d47c2e34885ed1908ad667061" +checksum = "7b50fa271071aae2e6ee85f842e2e28ba8cd2c5fb67f11fcb1fd70b276f9e7d4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -527,11 +596,17 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "wasm-bindgen" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d15e63b4482863c109d70a7b8706c1e364eb6ea449b201a76c5b89cedcec2d5c" +checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" dependencies = [ "cfg-if", "once_cell", @@ -540,24 +615,23 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d36ef12e3aaca16ddd3f67922bc63e48e953f126de60bd33ccc0101ef9998cd" +checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "705440e08b42d3e4b36de7d66c944be628d579796b8090bfa3471478a2260051" +checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -565,22 +639,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98c9ae5a76e46f4deecd0f0255cc223cfa18dc9b261213b8aa0c7b36f61b3f1d" +checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ee99da9c5ba11bd675621338ef6fa52296b76b83305e9b6e5c77d4c286d6d49" +checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" [[package]] name = "zerocopy" @@ -600,5 +674,5 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] diff --git a/src/html/text_type.rs b/src/html/text_type.rs index 9bc4695a..d618091b 100644 --- a/src/html/text_type.rs +++ b/src/html/text_type.rs @@ -56,6 +56,7 @@ cfg_if! { } impl<'s> From<&'s str> for TextType { + #[allow(clippy::fallible_impl_from)] fn from(text_type: &'s str) -> Self { match text_type { "Data state" => Self::Data, diff --git a/src/parser/lexer/conditions.rs b/src/parser/lexer/conditions.rs index cf75f341..06c5df2c 100644 --- a/src/parser/lexer/conditions.rs +++ b/src/parser/lexer/conditions.rs @@ -1,4 +1,4 @@ -use super::*; +use super::{LexemeSink, Lexer, TagTokenOutline}; use crate::parser::state_machine::StateMachineConditions; impl StateMachineConditions for Lexer { diff --git a/src/parser/tag_scanner/conditions.rs b/src/parser/tag_scanner/conditions.rs index b7e298f6..89efb987 100644 --- a/src/parser/tag_scanner/conditions.rs +++ b/src/parser/tag_scanner/conditions.rs @@ -1,4 +1,4 @@ -use super::*; +use super::{TagHintSink, TagScanner}; use crate::parser::state_machine::StateMachineConditions; impl StateMachineConditions for TagScanner { diff --git a/src/parser/tag_scanner/mod.rs b/src/parser/tag_scanner/mod.rs index 93982e0a..51468a1e 100644 --- a/src/parser/tag_scanner/mod.rs +++ b/src/parser/tag_scanner/mod.rs @@ -134,12 +134,11 @@ impl TagScanner { fn take_feedback_directive(&mut self) -> FeedbackDirective { self.pending_text_type_change .take() - .map(|text_type| { + .map_or(FeedbackDirective::Skip, |text_type| { FeedbackDirective::ApplyUnhandledFeedback(TreeBuilderFeedback::SwitchTextType( text_type, )) }) - .unwrap_or(FeedbackDirective::Skip) } } diff --git a/src/rewritable_units/element.rs b/src/rewritable_units/element.rs index b3e13cf8..85bd1093 100644 --- a/src/rewritable_units/element.rs +++ b/src/rewritable_units/element.rs @@ -1439,7 +1439,11 @@ mod tests { #[test] fn parsed() { test!( - |_| {}, + |el| { + assert_eq!(el.get_attribute("a1").unwrap(), "foo \" baré \" baz"); + assert_eq!(el.get_attribute("a3").unwrap(), "foo/bar"); + assert_eq!(el.get_attribute("a4").unwrap(), ""); + }, r#""# ); } @@ -1523,6 +1527,26 @@ mod tests { assert_eq!(output, r""); } + #[test] + fn value_trailing_slash() { + let mut output = rewrite_element(b"", UTF_8, "img", |el| { + assert_eq!(el.get_attribute("path").unwrap(), "//"); + el.set_attribute("slash", "/").unwrap(); + + assert!(!el.can_have_content()); + }); + + assert_eq!(output, r#""#); + + output = rewrite_element(b"", UTF_8, "img", |el| { + el.remove_attribute("path"); + + assert!(!el.can_have_content()); + }); + + assert_eq!(output, r""); + } + #[test] fn remove_non_existent_attr() { test!( @@ -1537,6 +1561,8 @@ mod tests { fn without_attrs() { test!( |el| { + assert!(el.can_have_content()); + for name in &["a1", "a2", "a3", "a4"] { el.remove_attribute(name); } diff --git a/src/rewritable_units/text_encoder.rs b/src/rewritable_units/text_encoder.rs index 0efca0c4..93daf086 100644 --- a/src/rewritable_units/text_encoder.rs +++ b/src/rewritable_units/text_encoder.rs @@ -142,16 +142,16 @@ impl Buffer { fn buffer_for_length(&mut self, content_len: usize) -> &mut [u8] { let buffer = match self { - Buffer::Heap(buf) => buf.as_mut_slice(), + Self::Heap(buf) => buf.as_mut_slice(), // Long non-ASCII content could take lots of roundtrips through the encoder buf if content_len >= Self::CONTENT_WRITE_LENGTH_LONG_ENOUGH_TO_USE_LARGER_BUFFER => { - *buf = Buffer::Heap(vec![0; Self::DEFAULT_HEAP_BUFFER_SIZE]); + *buf = Self::Heap(vec![0; Self::DEFAULT_HEAP_BUFFER_SIZE]); match buf { - Buffer::Heap(buf) => buf.as_mut(), + Self::Heap(buf) => buf.as_mut(), _ => unreachable!(), } } - Buffer::Stack(buf) => buf.as_mut_slice(), + Self::Stack(buf) => buf.as_mut_slice(), }; buffer } diff --git a/src/rewritable_units/tokens/start_tag.rs b/src/rewritable_units/tokens/start_tag.rs index a026f6eb..da00d89b 100644 --- a/src/rewritable_units/tokens/start_tag.rs +++ b/src/rewritable_units/tokens/start_tag.rs @@ -24,7 +24,7 @@ pub struct StartTag<'i> { impl<'i> StartTag<'i> { #[inline] #[must_use] - pub(super) fn new_token( + pub(super) const fn new_token( name: Bytes<'i>, attributes: Attributes<'i>, ns: Namespace, @@ -117,6 +117,9 @@ impl<'i> StartTag<'i> { self.self_closing } + /// If false, the tag won't be seiralized with `/>` + /// + /// This doesn't affect content model pub(crate) fn set_self_closing_syntax(&mut self, has_slash: bool) { self.self_closing = has_slash; } diff --git a/src/rewriter/handlers_dispatcher.rs b/src/rewriter/handlers_dispatcher.rs index c41d249b..7002e491 100644 --- a/src/rewriter/handlers_dispatcher.rs +++ b/src/rewriter/handlers_dispatcher.rs @@ -185,7 +185,7 @@ impl<'h, H: HandlerTypes> ContentHandlersDispatcher<'h, H> { } #[inline] - pub fn start_matching(&mut self, match_info: MatchInfo) { + pub fn start_matching(&mut self, match_info: &MatchInfo) { let locator = match_info.payload; if match_info.with_content { diff --git a/src/rewriter/mod.rs b/src/rewriter/mod.rs index ac336960..29256c27 100644 --- a/src/rewriter/mod.rs +++ b/src/rewriter/mod.rs @@ -5,7 +5,7 @@ mod rewrite_controller; pub(crate) mod settings; use self::handlers_dispatcher::ContentHandlersDispatcher; -use self::rewrite_controller::*; +use self::rewrite_controller::{ElementDescriptor, HtmlRewriteController}; pub use self::settings::*; use crate::base::SharedEncoding; use crate::memory::{MemoryLimitExceededError, SharedMemoryLimiter}; diff --git a/src/rewriter/rewrite_controller.rs b/src/rewriter/rewrite_controller.rs index 27930d74..a327d766 100644 --- a/src/rewriter/rewrite_controller.rs +++ b/src/rewriter/rewrite_controller.rs @@ -3,7 +3,7 @@ use super::{HandlerTypes, RewritingError}; use crate::html::{LocalName, Namespace}; use crate::rewritable_units::{DocumentEnd, Token, TokenCaptureFlags}; use crate::selectors_vm::{AuxStartTagInfoRequest, ElementData, SelectorMatchingVm, VmError}; -use crate::transform_stream::*; +use crate::transform_stream::{DispatcherError, StartTagHandlingResult, TransformController}; use hashbrown::HashSet; #[derive(Default)] @@ -48,7 +48,7 @@ impl HtmlRewriteController<'_, H> { Err(DispatcherError::InfoRequest(Box::new( move |this, aux_info| { if let Some(ref mut vm) = this.selector_matching_vm { - let mut match_handler = |m| this.handlers_dispatcher.start_matching(m); + let mut match_handler = |m| this.handlers_dispatcher.start_matching(&m); aux_info_req(vm, aux_info, &mut match_handler) .map_err(RewritingError::MemoryLimitExceeded)?; @@ -78,7 +78,7 @@ impl TransformController for HtmlRewriteController<'_, H> { ) -> StartTagHandlingResult { match self.selector_matching_vm { Some(ref mut vm) => { - let mut match_handler = |m| self.handlers_dispatcher.start_matching(m); + let mut match_handler = |m| self.handlers_dispatcher.start_matching(&m); match vm.exec_for_start_tag(local_name, ns, &mut match_handler) { Ok(()) => Ok(self.get_capture_flags()), diff --git a/src/selectors_vm/ast.rs b/src/selectors_vm/ast.rs index a18f17c4..e493af11 100644 --- a/src/selectors_vm/ast.rs +++ b/src/selectors_vm/ast.rs @@ -128,10 +128,10 @@ impl From<&Component> for Condition { Self::OnTagName(OnTagNameExpr::ExplicitAny) } Component::ExplicitNoNamespace => Self::OnTagName(OnTagNameExpr::Unmatchable), - Component::ID(id) => Self::OnAttributes(OnAttributesExpr::Id(id.0.to_owned())), - Component::Class(c) => Self::OnAttributes(OnAttributesExpr::Class(c.0.to_owned())), + Component::ID(id) => Self::OnAttributes(OnAttributesExpr::Id(id.0.clone())), + Component::Class(c) => Self::OnAttributes(OnAttributesExpr::Class(c.0.clone())), Component::AttributeInNoNamespaceExists { local_name, .. } => { - Self::OnAttributes(OnAttributesExpr::AttributeExists(local_name.0.to_owned())) + Self::OnAttributes(OnAttributesExpr::AttributeExists(local_name.0.clone())) } &Component::AttributeInNoNamespace { ref local_name, @@ -145,8 +145,8 @@ impl From<&Component> for Condition { } else { Self::OnAttributes(OnAttributesExpr::AttributeComparisonExpr( AttributeComparisonExpr::new( - local_name.0.to_owned(), - value.0.to_owned(), + local_name.0.clone(), + value.0.clone(), case_sensitivity, operator, ), diff --git a/src/selectors_vm/error.rs b/src/selectors_vm/error.rs index 9e4762b2..07ab4e9a 100644 --- a/src/selectors_vm/error.rs +++ b/src/selectors_vm/error.rs @@ -45,6 +45,11 @@ pub enum SelectorError { #[error("Invalid or unescaped class name in selector.")] InvalidClassName, + /// Unused + #[error("Empty negation in selector.")] + #[deprecated(note = "unused")] + EmptyNegation, + /// Unsupported combinator in the selector. #[error("Unsupported combinator `{0}` in selector.")] UnsupportedCombinator(char), @@ -89,7 +94,10 @@ impl From> for SelectorError { } // NOTE: there are currently no cases in the parser code // that trigger this error. - SelectorParseErrorKind::UnexpectedIdent(_) => unreachable!(), + SelectorParseErrorKind::UnexpectedIdent(_) => { + debug_assert!(false); + Self::UnsupportedSyntax + }, SelectorParseErrorKind::ExpectedNamespace(_) => Self::NamespacedSelector, SelectorParseErrorKind::ExplicitNamespaceUnexpectedToken(_) => { Self::UnexpectedToken @@ -101,7 +109,10 @@ impl From> for SelectorError { Self::UnexpectedTokenInAttribute } SelectorParseErrorKind::ClassNeedsIdent(_) => Self::InvalidClassName, - SelectorParseErrorKind::InvalidState => panic!("invalid state"), + SelectorParseErrorKind::InvalidState => { + debug_assert!(false, "invalid state"); + Self::UnsupportedSyntax + } }, } } diff --git a/src/selectors_vm/stack.rs b/src/selectors_vm/stack.rs index 313b177d..846f67f9 100644 --- a/src/selectors_vm/stack.rs +++ b/src/selectors_vm/stack.rs @@ -245,10 +245,10 @@ impl Stack { where 'a: 'i, // 'a outlives 'i, required to downcast 'a lifetimes into 'i { - let cumulative = match self.items.last() { - Some(last) => &last.child_counter, - None => &self.root_child_counter, - }; + let cumulative = self + .items + .last() + .map_or(&self.root_child_counter, |last| &last.child_counter); SelectorState { cumulative, typed: self