git.delta.rocks / jrsonnet / refs/commits / 0ad724252f64

difftreelog

refactor replace serde-yaml with serde-saphyr for yaml parsing

oxsqnpvmYaroslav Bolyukin2026-02-07parent: #8a3d104.patch.diff
in: master

4 files changed

modifiedCargo.lockdiffbeforeafterboth
before · Cargo.lock
170 packageslockfile v4
modifiedCargo.tomldiffbeforeafterboth
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -35,11 +35,9 @@
 clap_complete = "4.5"
 
 # Parsing, manifestification is implemented manually everywhere
-# Note on serde_yaml_with_quirks: This is a fork of serde-yaml with legacy yaml 1.1 support:
-# https://github.com/dtolnay/serde-yaml/pull/225
 serde = "1.0.228"
 serde_json = "1.0.149"
-serde_yaml_with_quirks = "0.9.34"
+serde-saphyr = {version = "0.0.17", default-features = false}
 
 # Error handling
 anyhow = "1.0.101"
modifiedcrates/jrsonnet-stdlib/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/Cargo.toml
+++ b/crates/jrsonnet-stdlib/Cargo.toml
@@ -41,8 +41,8 @@
 base64.workspace = true
 # std.parseJson
 serde_json.workspace = true
-# std.parseYaml, custom library fork is used for C++/golang compatibility
-serde_yaml_with_quirks.workspace = true
+# std.parseYaml
+serde-saphyr.workspace = true
 
 num-bigint = { workspace = true, optional = true }
 
modifiedcrates/jrsonnet-stdlib/src/parse.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/parse.rs
+++ b/crates/jrsonnet-stdlib/src/parse.rs
@@ -1,5 +1,4 @@
 use jrsonnet_evaluator::{function::builtin, runtime_error, IStr, Result, Val};
-use serde::Deserialize;
 
 #[builtin]
 pub fn builtin_parse_json(str: IStr) -> Result<Val> {
@@ -10,17 +9,17 @@
 
 #[builtin]
 pub fn builtin_parse_yaml(str: IStr) -> Result<Val> {
-	use serde_yaml_with_quirks::DeserializingQuirks;
-	let value = serde_yaml_with_quirks::Deserializer::from_str_with_quirks(
+	let out = serde_saphyr::from_multiple_with_options::<Val>(
 		&str,
-		DeserializingQuirks { old_octals: true },
-	);
-	let mut out = vec![];
-	for item in value {
-		let val =
-			Val::deserialize(item).map_err(|e| runtime_error!("failed to parse yaml: {e}"))?;
-		out.push(val);
-	}
+		serde_saphyr::Options {
+			// Golang/C++ compat
+			legacy_octal_numbers: true,
+			// Disable budget limits - we trust the YAML input
+			budget: None,
+			..Default::default()
+		},
+	)
+	.map_err(|e| runtime_error!("failed to parse yaml: {e}"))?;
 	Ok(if out.is_empty() {
 		Val::Null
 	} else if out.len() == 1 {