mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Replace pct-str with local ascii_percent_encoding
This commit is contained in:
parent
0b206b8a81
commit
c888ccc285
5 changed files with 51 additions and 73 deletions
|
@ -54,10 +54,6 @@ ignore = true
|
||||||
unknown-registry = "warn"
|
unknown-registry = "warn"
|
||||||
unknown-git = "warn"
|
unknown-git = "warn"
|
||||||
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
|
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
|
||||||
allow-git = [
|
|
||||||
# https://github.com/timothee-haudebourg/pct-str/issues/5
|
|
||||||
"https://github.com/timothee-haudebourg/pct-str.git",
|
|
||||||
]
|
|
||||||
|
|
||||||
[sources.allow-org]
|
[sources.allow-org]
|
||||||
github = ["ankitects"]
|
github = ["ankitects"]
|
||||||
|
|
56
Cargo.lock
generated
56
Cargo.lock
generated
|
@ -83,6 +83,7 @@ version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ammonia",
|
"ammonia",
|
||||||
"anki_i18n",
|
"anki_i18n",
|
||||||
|
"ascii_percent_encoding",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"blake3",
|
"blake3",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
@ -108,7 +109,6 @@ dependencies = [
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
"num_enum",
|
"num_enum",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"pct-str",
|
|
||||||
"pin-project",
|
"pin-project",
|
||||||
"prost",
|
"prost",
|
||||||
"prost-build",
|
"prost-build",
|
||||||
|
@ -141,7 +141,7 @@ dependencies = [
|
||||||
"which",
|
"which",
|
||||||
"workspace-hack",
|
"workspace-hack",
|
||||||
"zip",
|
"zip",
|
||||||
"zstd 0.12.0+zstd.1.5.2",
|
"zstd 0.12.1+zstd.1.5.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -210,7 +210,7 @@ dependencies = [
|
||||||
"workspace-hack",
|
"workspace-hack",
|
||||||
"xz2",
|
"xz2",
|
||||||
"zip",
|
"zip",
|
||||||
"zstd 0.12.0+zstd.1.5.2",
|
"zstd 0.12.1+zstd.1.5.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -225,6 +225,10 @@ version = "0.7.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6"
|
checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ascii_percent_encoding"
|
||||||
|
version = "0.0.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-trait"
|
name = "async-trait"
|
||||||
version = "0.1.59"
|
version = "0.1.59"
|
||||||
|
@ -985,9 +989,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "filetime"
|
name = "filetime"
|
||||||
version = "0.2.18"
|
version = "0.2.19"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4b9663d381d07ae25dc88dbdf27df458faa83a9b25336bcac83d5e452b5fc9d3"
|
checksum = "4e884668cd0c7480504233e951174ddc3b382f7c2666e3b7310b5c4e7b0c37f9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
|
@ -1623,9 +1627,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ipnet"
|
name = "ipnet"
|
||||||
version = "2.5.1"
|
version = "2.6.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f88c5561171189e69df9d98bcf18fd5f9558300f7ea7b801eb8a0fd748bd8745"
|
checksum = "ec947b7a4ce12e3b87e353abae7ce124d025b6c7d6c5aea5cc0bcf92e9510ded"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "is-terminal"
|
name = "is-terminal"
|
||||||
|
@ -2134,9 +2138,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl"
|
name = "openssl"
|
||||||
version = "0.10.43"
|
version = "0.10.44"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "020433887e44c27ff16365eaa2d380547a94544ad509aff6eb5b6e3e0b27b376"
|
checksum = "29d971fd5722fec23977260f6e81aa67d2f22cadbdc2aa049f1022d9a3be1566"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
|
@ -2166,9 +2170,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl-sys"
|
name = "openssl-sys"
|
||||||
version = "0.9.78"
|
version = "0.9.79"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "07d5c8cb6e57b3a3612064d7b18b117912b4ce70955c2504d4b741c9e244b132"
|
checksum = "5454462c0eced1e97f2ec09036abc8da362e66802f66fd20f86854d9d8cbcbc4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"cc",
|
"cc",
|
||||||
|
@ -2256,14 +2260,6 @@ dependencies = [
|
||||||
"sha2",
|
"sha2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pct-str"
|
|
||||||
version = "1.1.0"
|
|
||||||
source = "git+https://github.com/timothee-haudebourg/pct-str.git?rev=4adccd8d4a222ab2672350a102f06ae832a0572d#4adccd8d4a222ab2672350a102f06ae832a0572d"
|
|
||||||
dependencies = [
|
|
||||||
"utf8-decode",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pem"
|
name = "pem"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
@ -3014,9 +3010,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustix"
|
name = "rustix"
|
||||||
version = "0.36.4"
|
version = "0.36.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cb93e85278e08bb5788653183213d3a60fc242b10cb9be96586f5a73dcb67c23"
|
checksum = "a3807b5d10909833d3e9acd1eb5fb988f79376ff10fce42937de71a449c4c588"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"errno",
|
"errno",
|
||||||
|
@ -3693,9 +3689,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.22.0"
|
version = "1.23.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d76ce4a75fb488c605c54bf610f221cea8b0dafb53333c1a67e8ee199dcd2ae3"
|
checksum = "eab6d665857cc6ca78d6e80303a02cea7a7851e85dfbd77cbdc09bd129f1ef46"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
@ -3708,7 +3704,7 @@ dependencies = [
|
||||||
"signal-hook-registry",
|
"signal-hook-registry",
|
||||||
"socket2",
|
"socket2",
|
||||||
"tokio-macros",
|
"tokio-macros",
|
||||||
"winapi",
|
"windows-sys 0.42.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -4043,12 +4039,6 @@ version = "0.7.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
|
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "utf8-decode"
|
|
||||||
version = "1.0.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ca61eb27fa339aa08826a29f03e87b99b4d8f0fc2255306fd266bb1b6a9de498"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "utime"
|
name = "utime"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
|
@ -4394,7 +4384,7 @@ dependencies = [
|
||||||
"tokio",
|
"tokio",
|
||||||
"url",
|
"url",
|
||||||
"zip",
|
"zip",
|
||||||
"zstd 0.12.0+zstd.1.5.2",
|
"zstd 0.12.1+zstd.1.5.2",
|
||||||
"zstd-safe 6.0.2+zstd.1.5.2",
|
"zstd-safe 6.0.2+zstd.1.5.2",
|
||||||
"zstd-sys",
|
"zstd-sys",
|
||||||
]
|
]
|
||||||
|
@ -4463,9 +4453,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zstd"
|
name = "zstd"
|
||||||
version = "0.12.0+zstd.1.5.2"
|
version = "0.12.1+zstd.1.5.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b8148aa921e9d53217ab9322f8553bd130f7ae33489db68b381d76137d2e6374"
|
checksum = "5c947d2adc84ff9a59f2e3c03b81aa4128acf28d6ad7d56273f7e8af14e47bea"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zstd-safe 6.0.2+zstd.1.5.2",
|
"zstd-safe 6.0.2+zstd.1.5.2",
|
||||||
]
|
]
|
||||||
|
|
|
@ -116,6 +116,15 @@
|
||||||
"license_file": null,
|
"license_file": null,
|
||||||
"description": "A vector with fixed capacity, backed by an array (it can be stored on the stack too). Implements fixed capacity ArrayVec and ArrayString."
|
"description": "A vector with fixed capacity, backed by an array (it can be stored on the stack too). Implements fixed capacity ArrayVec and ArrayString."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "ascii_percent_encoding",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"authors": "The rust-url developers",
|
||||||
|
"repository": null,
|
||||||
|
"license": "Apache-2.0 OR MIT",
|
||||||
|
"license_file": null,
|
||||||
|
"description": "Like percent_encoding, but does not encode non-ASCII characters."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "async-trait",
|
"name": "async-trait",
|
||||||
"version": "0.1.59",
|
"version": "0.1.59",
|
||||||
|
@ -1054,7 +1063,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "ipnet",
|
"name": "ipnet",
|
||||||
"version": "2.5.1",
|
"version": "2.6.0",
|
||||||
"authors": "Kris Price <kris@krisprice.nz>",
|
"authors": "Kris Price <kris@krisprice.nz>",
|
||||||
"repository": "https://github.com/krisprice/ipnet",
|
"repository": "https://github.com/krisprice/ipnet",
|
||||||
"license": "Apache-2.0 OR MIT",
|
"license": "Apache-2.0 OR MIT",
|
||||||
|
@ -1396,7 +1405,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "openssl",
|
"name": "openssl",
|
||||||
"version": "0.10.43",
|
"version": "0.10.44",
|
||||||
"authors": "Steven Fackler <sfackler@gmail.com>",
|
"authors": "Steven Fackler <sfackler@gmail.com>",
|
||||||
"repository": "https://github.com/sfackler/rust-openssl",
|
"repository": "https://github.com/sfackler/rust-openssl",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
|
@ -1423,7 +1432,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "openssl-sys",
|
"name": "openssl-sys",
|
||||||
"version": "0.9.78",
|
"version": "0.9.79",
|
||||||
"authors": "Alex Crichton <alex@alexcrichton.com>|Steven Fackler <sfackler@gmail.com>",
|
"authors": "Alex Crichton <alex@alexcrichton.com>|Steven Fackler <sfackler@gmail.com>",
|
||||||
"repository": "https://github.com/sfackler/rust-openssl",
|
"repository": "https://github.com/sfackler/rust-openssl",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -1466,15 +1475,6 @@
|
||||||
"license_file": null,
|
"license_file": null,
|
||||||
"description": "Generic implementation of PBKDF2"
|
"description": "Generic implementation of PBKDF2"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "pct-str",
|
|
||||||
"version": "1.1.0",
|
|
||||||
"authors": "Timothée Haudebourg <author@haudebourg.net>",
|
|
||||||
"repository": "https://github.com/timothee-haudebourg/pct-str",
|
|
||||||
"license": "Apache-2.0 OR MIT",
|
|
||||||
"license_file": null,
|
|
||||||
"description": "Percent-encoded strings for URL, URI, IRI, etc."
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "percent-encoding",
|
"name": "percent-encoding",
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
|
@ -1846,7 +1846,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "rustix",
|
"name": "rustix",
|
||||||
"version": "0.36.4",
|
"version": "0.36.5",
|
||||||
"authors": "Dan Gohman <dev@sunfishcode.online>|Jakub Konka <kubkon@jakubkonka.com>",
|
"authors": "Dan Gohman <dev@sunfishcode.online>|Jakub Konka <kubkon@jakubkonka.com>",
|
||||||
"repository": "https://github.com/bytecodealliance/rustix",
|
"repository": "https://github.com/bytecodealliance/rustix",
|
||||||
"license": "Apache-2.0 OR Apache-2.0 WITH LLVM-exception OR MIT",
|
"license": "Apache-2.0 OR Apache-2.0 WITH LLVM-exception OR MIT",
|
||||||
|
@ -2359,7 +2359,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "tokio",
|
"name": "tokio",
|
||||||
"version": "1.22.0",
|
"version": "1.23.0",
|
||||||
"authors": "Tokio Contributors <team@tokio.rs>",
|
"authors": "Tokio Contributors <team@tokio.rs>",
|
||||||
"repository": "https://github.com/tokio-rs/tokio",
|
"repository": "https://github.com/tokio-rs/tokio",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -2645,15 +2645,6 @@
|
||||||
"license_file": null,
|
"license_file": null,
|
||||||
"description": "Incremental, zero-copy UTF-8 decoding with error handling"
|
"description": "Incremental, zero-copy UTF-8 decoding with error handling"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "utf8-decode",
|
|
||||||
"version": "1.0.1",
|
|
||||||
"authors": "Timothée Haudebourg <author@haudebourg.net>",
|
|
||||||
"repository": "https://github.com/timothee-haudebourg/utf8-decode",
|
|
||||||
"license": "Apache-2.0 OR MIT",
|
|
||||||
"license_file": null,
|
|
||||||
"description": "UTF-8 incremental decoding iterators."
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "utime",
|
"name": "utime",
|
||||||
"version": "0.3.1",
|
"version": "0.3.1",
|
||||||
|
@ -2989,7 +2980,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "zstd",
|
"name": "zstd",
|
||||||
"version": "0.12.0+zstd.1.5.2",
|
"version": "0.12.1+zstd.1.5.2",
|
||||||
"authors": "Alexandre Bury <alexandre.bury@gmail.com>",
|
"authors": "Alexandre Bury <alexandre.bury@gmail.com>",
|
||||||
"repository": "https://github.com/gyscos/zstd-rs",
|
"repository": "https://github.com/gyscos/zstd-rs",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
|
@ -41,9 +41,9 @@ features = ["json", "socks", "stream", "multipart"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anki_i18n = { path = "i18n" }
|
anki_i18n = { path = "i18n" }
|
||||||
|
ascii_percent_encoding = { path = "ascii_percent_encoding" }
|
||||||
|
|
||||||
csv = { git = "https://github.com/ankitects/rust-csv.git", rev = "1c9d3aab6f79a7d815c69f925a46a4590c115f90" }
|
csv = { git = "https://github.com/ankitects/rust-csv.git", rev = "1c9d3aab6f79a7d815c69f925a46a4590c115f90" }
|
||||||
pct-str = { git = "https://github.com/timothee-haudebourg/pct-str.git", rev = "4adccd8d4a222ab2672350a102f06ae832a0572d" }
|
|
||||||
|
|
||||||
# pinned as any changes could invalidate sqlite indexes
|
# pinned as any changes could invalidate sqlite indexes
|
||||||
unicase = "=2.6.0"
|
unicase = "=2.6.0"
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
use ascii_percent_encoding::{percent_decode_str, utf8_percent_encode, AsciiSet, CONTROLS};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use pct_str::{IriReserved, PctStr, PctString};
|
|
||||||
use regex::{Captures, Regex};
|
use regex::{Captures, Regex};
|
||||||
use unicase::eq as uni_eq;
|
use unicase::eq as uni_eq;
|
||||||
use unicode_normalization::{
|
use unicode_normalization::{
|
||||||
|
@ -487,25 +487,26 @@ lazy_static! {
|
||||||
pub(crate) static ref REMOTE_FILENAME: Regex = Regex::new("(?i)^https?://").unwrap();
|
pub(crate) static ref REMOTE_FILENAME: Regex = Regex::new("(?i)^https?://").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// https://url.spec.whatwg.org/#fragment-percent-encode-set
|
||||||
|
const FRAGMENT_QUERY_UNION: &AsciiSet = &CONTROLS
|
||||||
|
.add(b' ')
|
||||||
|
.add(b'"')
|
||||||
|
.add(b'<')
|
||||||
|
.add(b'>')
|
||||||
|
.add(b'`')
|
||||||
|
.add(b'#');
|
||||||
|
|
||||||
/// IRI-encode unescaped local paths in HTML fragment.
|
/// IRI-encode unescaped local paths in HTML fragment.
|
||||||
pub(crate) fn encode_iri_paths(unescaped_html: &str) -> Cow<str> {
|
pub(crate) fn encode_iri_paths(unescaped_html: &str) -> Cow<str> {
|
||||||
transform_html_paths(unescaped_html, |fname| {
|
transform_html_paths(unescaped_html, |fname| {
|
||||||
PctString::encode(fname.chars(), IriReserved::Segment)
|
utf8_percent_encode(fname, FRAGMENT_QUERY_UNION).into()
|
||||||
.into_string()
|
|
||||||
.into()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// URI-decode escaped local paths in HTML fragment.
|
/// URI-decode escaped local paths in HTML fragment.
|
||||||
pub(crate) fn decode_iri_paths(escaped_html: &str) -> Cow<str> {
|
pub(crate) fn decode_iri_paths(escaped_html: &str) -> Cow<str> {
|
||||||
transform_html_paths(escaped_html, |fname| {
|
transform_html_paths(escaped_html, |fname| {
|
||||||
match PctStr::new(fname) {
|
percent_decode_str(fname).decode_utf8_lossy()
|
||||||
Ok(s) => s.decode().into(),
|
|
||||||
Err(_e) => {
|
|
||||||
// invalid percent encoding; return unchanged
|
|
||||||
fname.into()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue