diff --git a/ethbloom/Cargo.toml b/ethbloom/Cargo.toml index 16de3c0..99385fd 100644 --- a/ethbloom/Cargo.toml +++ b/ethbloom/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ethbloom" -version = "0.6.0" +version = "0.6.1" authors = ["Parity Technologies "] description = "Ethereum bloom filter" license = "MIT" @@ -18,6 +18,7 @@ serde = { version = "1.0", optional = true } [dev-dependencies] rand = { version = "0.4" } hex-literal = "0.1.1" +rustc-hex = "1.0" [features] default = ["std", "heapsize", "serialize", "fixed-hash/libc", "fixed-hash/rustc-hex"] diff --git a/ethereum-types/Cargo.toml b/ethereum-types/Cargo.toml index 8f53d7b..51ad9f1 100644 --- a/ethereum-types/Cargo.toml +++ b/ethereum-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ethereum-types" -version = "0.5.0" +version = "0.5.1" authors = ["Parity Technologies "] license = "MIT" homepage = "https://github.com/paritytech/primitives" diff --git a/ethereum-types/src/uint.rs b/ethereum-types/src/uint.rs index 88aeb29..87fe2b0 100644 --- a/ethereum-types/src/uint.rs +++ b/ethereum-types/src/uint.rs @@ -188,6 +188,7 @@ mod tests { } // Invalid examples + assert!(ser::from_str::<$name>("\"∀∂\"").unwrap_err().is_data()); assert!(ser::from_str::<$name>("\"0x\"").unwrap_err().is_data()); assert!(ser::from_str::<$name>("\"0xg\"").unwrap_err().is_data()); assert!(ser::from_str::<$name>("\"\"").unwrap_err().is_data()); @@ -324,4 +325,4 @@ mod tests { let result = U256([1, 2, 3, 4]).full_mul(U256([5, 6, 7, 8])); assert_eq!(U512([5, 16, 34, 60, 61, 52, 32, 0]), result); } -} \ No newline at end of file +} diff --git a/serialize/src/lib.rs b/serialize/src/lib.rs index 7691dd1..91c7e3d 100644 --- a/serialize/src/lib.rs +++ b/serialize/src/lib.rs @@ -86,7 +86,7 @@ pub fn deserialize_check_len<'a, 'de, D>(deserializer: D, len: ExpectedLen<'a>) } fn visit_str(self, v: &str) -> Result { - if v.len() < 2 || &v[0..2] != "0x" { + if !v.starts_with("0x") { return Err(E::custom("prefix is missing")) } @@ -119,7 +119,7 @@ pub fn deserialize_check_len<'a, 'de, D>(deserializer: D, len: ExpectedLen<'a>) continue } _ => { - let ch = v[idx..].chars().next().unwrap(); + let ch = v.bytes().skip(idx).next().unwrap() as char; return Err(E::custom(&format!("invalid hex character: {}, at {}", ch, idx))) } }