Fix parsing JSON containing URLs with escaping
Scenario: PHP escapes slashes when encoding JSON. Any escaping in a string
means Serde cannot return a string slice anymore, only an owned string. Our URL
parsing was relying on deserializing as a string slice.
@@ -10,7 +10,7 @@ pub struct UrlDef;
impl UrlDef {
pub fn deserialize<'de, D>(deserializer: D) -> Result<Url, D::Error>
where D: Deserializer<'de> {
- <&str>::deserialize(deserializer).and_then(|s| {
+ <String>::deserialize(deserializer).and_then(|s| {
s.parse().map_err(|e| DeserializeError::custom(format!("invalid URL: {}", e)))
})
}
