From 10c00751bb573299e6b729665bec03d5db726846 Mon Sep 17 00:00:00 2001 From: Elizabeth Dinella Date: Tue, 3 Jan 2023 18:30:31 -0500 Subject: [PATCH 1/2] fixed issue#2004 parsing solc verison with trailing newlines --- ethers-solc/src/compile/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/ethers-solc/src/compile/mod.rs b/ethers-solc/src/compile/mod.rs index b34913fe5..925125b74 100644 --- a/ethers-solc/src/compile/mod.rs +++ b/ethers-solc/src/compile/mod.rs @@ -686,6 +686,7 @@ fn version_from_output(output: Output) -> Result { let version = output .stdout .lines() + .filter(|l| !l.as_ref().unwrap().is_empty()) .last() .ok_or_else(|| SolcError::solc("version not found in solc output"))? .map_err(|err| SolcError::msg(format!("Failed to read output: {err}")))?; From 878c595d095f52a2fd2eeb511a3a150fe5db9112 Mon Sep 17 00:00:00 2001 From: Elizabeth Dinella Date: Fri, 6 Jan 2023 14:43:49 -0500 Subject: [PATCH 2/2] suggested changes --- ethers-solc/src/compile/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ethers-solc/src/compile/mod.rs b/ethers-solc/src/compile/mod.rs index 925125b74..b6a356e6c 100644 --- a/ethers-solc/src/compile/mod.rs +++ b/ethers-solc/src/compile/mod.rs @@ -686,10 +686,10 @@ fn version_from_output(output: Output) -> Result { let version = output .stdout .lines() - .filter(|l| !l.as_ref().unwrap().is_empty()) + .filter_map(|l| l.ok()) + .filter(|l| !l.trim().is_empty()) .last() - .ok_or_else(|| SolcError::solc("version not found in solc output"))? - .map_err(|err| SolcError::msg(format!("Failed to read output: {err}")))?; + .ok_or_else(|| SolcError::solc("version not found in solc output"))?; // NOTE: semver doesn't like `+` in g++ in build metadata which is invalid semver Ok(Version::from_str(&version.trim_start_matches("Version: ").replace(".g++", ".gcc"))?) } else {