Skip to content

Commit

Permalink
escaping double quotes in literals
Browse files Browse the repository at this point in the history
  • Loading branch information
cordawyn committed Oct 24, 2012
1 parent c47d65c commit f95df42
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Database/HSparql/QueryGenerator.hs
Expand Up @@ -71,6 +71,7 @@ where

import Control.Monad.State
import Data.List (intercalate)
import Data.String.Utils


-- State monads
Expand Down Expand Up @@ -498,9 +499,9 @@ instance QueryShow (Maybe IRIRef) where
qshow Nothing = ""

instance QueryShow RDFLiteral where
qshow (RDFLiteral s) = "\"" ++ s ++ "\""
qshow (RDFLiteralLang s lang') = "\"" ++ s ++ "\"@" ++ lang'
qshow (RDFLiteralIRIRef s ref) = "\"" ++ s ++ "\"^^" ++ qshow ref
qshow (RDFLiteral s) = "\"" ++ escapeQuotes s ++ "\""
qshow (RDFLiteralLang s lang') = "\"" ++ escapeQuotes s ++ "\"@" ++ lang'
qshow (RDFLiteralIRIRef s ref) = "\"" ++ escapeQuotes s ++ "\"^^" ++ qshow ref

instance QueryShow GraphTerm where
qshow (IRIRefTerm ref) = qshow ref
Expand Down Expand Up @@ -610,3 +611,9 @@ instance QueryShow QueryData where
, qshow (AskForm qd)
]
in query


-- Internal utilities

escapeQuotes :: String -> String
escapeQuotes s = replace "\"" "\\\"" s
2 changes: 2 additions & 0 deletions hsparql.cabal
Expand Up @@ -29,6 +29,7 @@ library
, xml
, rdf4h >= 1.0.0
, bytestring
, MissingH
, network
, text
extensions: RankNTypes FlexibleInstances
Expand All @@ -45,6 +46,7 @@ test-suite test-hsparql
, HUnit
, test-framework
, test-framework-hunit
, MissingH
, wai
, warp
hs-source-dirs: Database, tests
Expand Down

0 comments on commit f95df42

Please sign in to comment.