Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect parsing of quotes in strings #29

Open
gaverhae opened this issue Apr 8, 2018 · 2 comments
Open

Incorrect parsing of quotes in strings #29

gaverhae opened this issue Apr 8, 2018 · 2 comments

Comments

@gaverhae
Copy link

gaverhae commented Apr 8, 2018

(venia.core/graphql-query {:venia/queries [[:q {:arg "he\"llo"} [:prop]]]})
;=> "{q(arg:\"he\"llo\"){prop}}"

I would expect the literal quote in the string to be escaped. The return value in this case is not a valid GraphQL query.

I'm not familiar enough with the GraphQL spec to know if there are other characters that need to be escaped.

@gaverhae
Copy link
Author

gaverhae commented Apr 8, 2018

If it's any help, in my case I've solved it with:

(ns ...
  (:require [clojure.walk :as walk]
            [clojure.string :as string]
            [venia.core :as v]))

;; [...]

(defn ->queries [& queries]
  (let [sanitized-queries (walk/postwalk (fn [v] (if (string? v)
                                                   (string/escape v {\" "\\\""})
                                                   v))
                                         queries)]
    (v/graphql-query {:venia/queries sanitized-queries})))

@xfthhxk
Copy link
Contributor

xfthhxk commented May 15, 2018

I ran into this also. PR #31 addresses this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants