Skip to content

Commit

Permalink
quad: do not un-quote strings in StringToValue; fixes #710
Browse files Browse the repository at this point in the history
  • Loading branch information
dennwc committed Apr 23, 2018
1 parent 5cc0e45 commit 009b1f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions quad/quad.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ func Make(subject, predicate, object, label interface{}) (q Quad) {
// Deprecated: use Make pr MakeIRI instead.
func MakeRaw(subject, predicate, object, label string) (q Quad) {
if subject != "" {
q.Subject = StringToValue(subject)
q.Subject = Raw(subject)
}
if predicate != "" {
q.Predicate = StringToValue(predicate)
q.Predicate = Raw(predicate)
}
if object != "" {
q.Object = StringToValue(object)
q.Object = Raw(object)
}
if label != "" {
q.Label = StringToValue(label)
q.Label = Raw(label)
}
return
}
Expand Down
5 changes: 3 additions & 2 deletions quad/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ func StringToValue(v string) Value {
if len(v) > 2 {
if v[0] == '<' && v[len(v)-1] == '>' {
return IRI(v[1 : len(v)-1])
} else if v[0] == '"' && v[len(v)-1] == '"' {
return String(v[1 : len(v)-1])
} else if v[:2] == "_:" {
return BNode(v[2:])
} else if i := strings.Index(v, `"^^<`); i > 0 && v[0] == '"' && v[len(v)-1] == '>' {
Expand All @@ -149,6 +147,9 @@ func ToString(v Value) string {
//
// Deprecated: use IRI or String instead.
func Raw(s string) Value {
if len(s) >= 2 && s[0] == '"' && s[len(s)-1] == '"' {
return String(s[1 : len(s)-1])
}
return StringToValue(s)
}

Expand Down

0 comments on commit 009b1f6

Please sign in to comment.