Skip to content

Commit fff99a9

Browse files
committed
fix: json5 unmaintained, RUSTSEC-2025-0120
1 parent e47f0b9 commit fff99a9

File tree

6 files changed

+25
-22
lines changed

6 files changed

+25
-22
lines changed

Cargo.lock

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ tracing-appender = { version = "0.2.3", optional = true, default-features = fals
218218
time = { version = "0.3", optional = true }
219219

220220
serde = { version = "1.0", features = ["derive"] }
221-
json5 = "0.4"
221+
serde_json5 = "0.2"
222222
thiserror = "2.0"
223223
base64 = "0.22"
224224

crates/shadowsocks-service/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ hickory-resolver = { version = "0.25", optional = true, features = ["serde"] }
170170
idna = "1.0"
171171
ipnet = "2.10"
172172
iprange = "0.6"
173-
regex = { version = "1.4", default-features = false, features = ["std", "perf"] }
173+
regex = { version = "1.4", default-features = false, features = [
174+
"std",
175+
"perf",
176+
] }
174177

175178
mime = { version = "0.3", optional = true }
176179
flate2 = { version = "1.0", optional = true }
@@ -192,7 +195,7 @@ smoltcp = { version = "0.12", optional = true, default-features = false, feature
192195
] }
193196

194197
serde = { version = "1.0", features = ["derive"] }
195-
json5 = "0.4"
198+
serde_json5 = "0.2"
196199
bson = { version = "3.0.0", features = ["serde"], optional = true }
197200

198201
shadowsocks = { version = "1.23.2", path = "../shadowsocks", default-features = false }

crates/shadowsocks-service/src/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,7 +1457,7 @@ macro_rules! impl_from {
14571457
}
14581458

14591459
impl_from!(::std::io::Error, ErrorKind::IoError, "error while reading file");
1460-
impl_from!(json5::Error, ErrorKind::JsonParsingError, "json parse error");
1460+
impl_from!(serde_json5::Error, ErrorKind::JsonParsingError, "json parse error");
14611461

14621462
impl Debug for Error {
14631463
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
@@ -2564,7 +2564,7 @@ impl Config {
25642564

25652565
/// Load Config from a `str`
25662566
pub fn load_from_str(s: &str, config_type: ConfigType) -> Result<Self, Error> {
2567-
let c = json5::from_str::<SSConfig>(s)?;
2567+
let c = serde_json5::from_str::<SSConfig>(s)?;
25682568
Self::load_from_ssconfig(c, config_type)
25692569
}
25702570

@@ -3178,7 +3178,7 @@ impl fmt::Display for Config {
31783178
});
31793179
}
31803180

3181-
write!(f, "{}", json5::to_string(&jconf).unwrap())
3181+
write!(f, "{}", serde_json5::to_string(&jconf).unwrap())
31823182
}
31833183
}
31843184

crates/shadowsocks-service/src/local/socks/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl Socks5AuthConfig {
6666
let mut content = String::new();
6767
reader.read_to_string(&mut content)?;
6868

69-
let jconf: SSSocks5AuthConfig = match json5::from_str(&content) {
69+
let jconf: SSSocks5AuthConfig = match serde_json5::from_str(&content) {
7070
Ok(c) => c,
7171
Err(err) => return Err(io::Error::other(err)),
7272
};

src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub enum ConfigError {
8888
IoError(#[from] io::Error),
8989
/// JSON parsing error
9090
#[error("{0}")]
91-
JsonError(#[from] json5::Error),
91+
JsonError(#[from] serde_json5::Error),
9292
/// Invalid value
9393
#[error("Invalid value: {0}")]
9494
InvalidValue(String),
@@ -120,7 +120,7 @@ impl Config {
120120

121121
/// Load `Config` from string
122122
pub fn load_from_str(s: &str) -> Result<Self, ConfigError> {
123-
json5::from_str(s).map_err(ConfigError::from)
123+
serde_json5::from_str(s).map_err(ConfigError::from)
124124
}
125125

126126
/// Set by command line options

0 commit comments

Comments
 (0)