Repository: golemfactory/yagna (language: python)

Issue:
Error parsing literal when receiving offer
`Error: ParseError { msg: "Error parsing literal: '\"hash:sha3:9a3b5d67b0b27746283cb5f287c13eab1beaa12d92a9f536b747c7ae:http://girepo.dev.golem.network:8000/local-image-c76719083b.gvmi\\n\"'" }`


Discussion / hints:

Fix patch:
diff --git a/core/market/resolver/src/resolver/prop_parser.rs b/core/market/resolver/src/resolver/prop_parser.rs
index bc91a3064e..1bd5a20bd2 100644
--- a/core/market/resolver/src/resolver/prop_parser.rs
+++ b/core/market/resolver/src/resolver/prop_parser.rs
@@ -174,7 +174,6 @@ named!(prop_ref_list_item <&str, &str>,
 #[derive(Debug, Clone, PartialEq)]
 pub enum Literal<'a> {
     Str(&'a str),
-    String(String),
     Number(&'a str),
     Decimal(&'a str),
     Bool(bool),
@@ -186,7 +185,7 @@ pub enum Literal<'a> {
 named!(
     val_literal<Literal>,
     alt!(
-        string_literal
+        str_literal
             | version_literal
             | datetime_literal
             | true_literal
@@ -211,20 +210,14 @@ named!(
 );
 
 named!(
-    string_literal<Literal>,
-    ws!(do_parse!(
-        val: delimited!(
-            tag!("\""),
-            escaped!(none_of!("\\\""), '\\', one_of!("\\\"")),
-            tag!("\"")
-        ) >> ({
-            let val = str::from_utf8(val).unwrap();
-            if !val.contains("\\\"") {
-                Literal::Str(val)
-            } else {
-                Literal::String(val.replace("\\\"", "\""))
-            }
-        })
+    str_literal<Literal>,
+    ws!(delimited!(
+        char!('"'),
+        do_parse!(
+            val: escaped!(none_of!(r#"\""#), '\\', one_of!("\"nt0\\"))
+                >> (Literal::Str(str::from_utf8(val).unwrap()))
+        ),
+        char!('"')
     ))
 );
 
@@ -443,31 +436,3 @@ pub fn is_equal_sign(chr: char) -> bool {
 pub fn is_delimiter(chr: char) -> bool {
     chr == '[' || chr == ']' || chr == '$'
 }
-
-#[cfg(test)]
-mod tests {
-    use super::*;
-
-    #[test]
-    fn default_parse() {
-        assert!(match string_literal("\"input\"".as_bytes()) {
-            IResult::Done(rest, t) => {
-                rest.len() == 0 && t == Literal::Str("input")
-            }
-            IResult::Error(_) => false,
-            IResult::Incomplete(_) => false,
-        })
-    }
-
-    #[test]
-    fn double_quoted_parse() {
-        assert!(
-            match string_literal("\"\\\"king\\\" \\\"node\\\"\"".as_bytes()) {
-                IResult::Done(rest, t) =>
-                    rest.len() == 0 && t == Literal::String(String::from("\"king\" \"node\"")),
-                IResult::Error(_) => false,
-                IResult::Incomplete(_) => false,
-            }
-        )
-    }
-}
diff --git a/core/market/resolver/src/resolver/properties.rs b/core/market/resolver/src/resolver/properties.rs
index 1bbbf06ca5..b61e7c7304 100644
--- a/core/market/resolver/src/resolver/properties.rs
+++ b/core/market/resolver/src/resolver/properties.rs
@@ -16,8 +16,7 @@ type d128 = BigDecimal;
 // #region PropertyValue
 #[derive(Debug, Clone, PartialEq)]
 pub enum PropertyValue<'a> {
-    Str(&'a str),   // Str
-    String(String), // String
+    Str(&'a str), // Str
     Boolean(bool),
     //Int(i32),
     //Long(i64),
@@ -57,7 +56,6 @@ impl<'a> PropertyValue<'a> {
                 Ok(result) => &result == value,
                 _ => false,
             }, // ignore parsing error, assume false
-            PropertyValue::String(value) => PropertyValue::str_equal_with_wildcard(other, value),
         }
     }
 
@@ -83,7 +81,6 @@ impl<'a> PropertyValue<'a> {
             }, // ignore parsing error, assume false
             PropertyValue::List(_) => false,             // operator meaningless for List
             PropertyValue::Boolean(_) => false,          // operator meaningless for bool
-            PropertyValue::String(value) => value.as_str() < other,
         }
     }
 
@@ -109,7 +106,6 @@ impl<'a> PropertyValue<'a> {
             }, // ignore parsing error, assume false
             PropertyValue::List(_) => false,              // operator meaningless for List
             PropertyValue::Boolean(_) => false,           // operator meaningless for bool
-            PropertyValue::String(value) => value.as_str() <= other,
         }
     }
 
@@ -135,7 +131,6 @@ impl<'a> PropertyValue<'a> {
             }, // ignore parsing error, assume false
             PropertyValue::List(_) => false,             // operator meaningless for List
             PropertyValue::Boolean(_) => false,          // operator meaningless for bool
-            PropertyValue::String(value) => value.as_str() > other,
         }
     }
 
@@ -161,7 +156,6 @@ impl<'a> PropertyValue<'a> {
             }, // ignore parsing error, assume false
             PropertyValue::List(_) => false,              // operator meaningless for List
             PropertyValue::Boolean(_) => false,           // operator meaningless for bool
-            PropertyValue::String(value) => value.as_str() >= other,
         }
     }
 
@@ -314,7 +308,6 @@ impl<'a> PropertyValue<'a> {
                         .collect(),
                 ))
             }
-            Literal::String(val) => Ok(PropertyValue::String(val)),
         }
     }
 


Test patch:
diff --git a/core/market/resolver/tests/prop-parser.rs b/core/market/resolver/tests/prop-parser.rs
index 13dbc94f71..8975068847 100644
--- a/core/market/resolver/tests/prop-parser.rs
+++ b/core/market/resolver/tests/prop-parser.rs
@@ -100,19 +100,31 @@ fn parse_prop_ref_as_list_syntax_error2() {
 #[test]
 fn parse_prop_value_from_literal_string() {
     assert_eq!(
-        parse_prop_value_literal("\"dblah\""),
+        parse_prop_value_literal(r#""dblah""#),
         Ok(Literal::Str("dblah"))
     );
 }
 
 #[test]
-fn parse_prop_value_from_literal_string_with_escaped_quotes() {
+fn parse_prop_value_from_literal_string_with_quotes() {
     assert_eq!(
-        parse_prop_value_literal("\"\\\"king\\\" \\\"node\\\"\""),
-        Ok(Literal::String(String::from("\"king\" \"node\"")))
+        parse_prop_value_literal(r#""one \"two\" \tthree\n""#),
+        Ok(Literal::Str(r#"one \"two\" \tthree\n"#))
     );
 }
 
+#[test]
+fn parse_prop() {
+    assert_eq!(
+        parse_prop_value_literal(
+            r#""hash:sha3:aabb:http://repo.some.network:8000/some-image-ddee0011.gvmi\n""#
+        ),
+        Ok(Literal::Str(
+            r#"hash:sha3:aabb:http://repo.some.network:8000/some-image-ddee0011.gvmi\n"#
+        ))
+    )
+}
+
 #[test]
 fn parse_prop_value_from_literal_datetime() {
     assert_eq!(