summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDaniel Gnoutcheff <gnoutchd@softwarefreedom.org>2021-09-15 11:53:04 -0400
committerDaniel Gnoutcheff <gnoutchd@softwarefreedom.org>2021-09-15 11:53:04 -0400
commitb97904c85f21bfb485f110b5b4f84abc5d6b0b66 (patch)
treef48a31e0e54b4107d6062ae9f127850797649e96 /app
parent916a68adab4e3e021179be67d79db050f7198070 (diff)
Unescape input messages
Diffstat (limited to 'app')
-rw-r--r--app/Main.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/app/Main.hs b/app/Main.hs
index eab879e..c5275b6 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -13,7 +13,7 @@ import Data.List.Split (chop)
import qualified Network.XmlRpc.DTD_XMLRPC as XR
import Text.XML.HaXml.XmlContent (Document (..), toXml, fromXml)
import qualified Text.XML.HaXml.ByteStringPP as XPP
-import Text.XML.HaXml.Escape (xmlEscape, stdXmlEscaper)
+import Text.XML.HaXml.Escape (xmlEscape, xmlUnEscape, stdXmlEscaper)
import qualified Text.Pandoc as P
-- Modified version of XMLParse.document that doesn't wait for anything after
@@ -50,7 +50,7 @@ plugin (i:is) = case parseRpcCall i of
type RpcArgs = [(String, XR.Value_)]
parseRpcCall :: Document Posn -> Maybe (String, RpcArgs)
-parseRpcCall doc = case fromXml doc of
+parseRpcCall doc = case fromXml (unEscapeDoc doc) of
Right (XR.MethodCall (XR.MethodName method) mArgs) ->
Just . (,) method $ case mArgs of
Just (XR.Params params) -> flattenParams params
@@ -64,6 +64,9 @@ parseRpcCall doc = case fromXml doc of
) = (key, val) : flattenParams ps
flattenParams _ = error "args not in named-value format"
+unEscapeDoc :: Document i -> Document i
+unEscapeDoc (Document p s e m) = Document p s (xmlUnEscape stdXmlEscaper e) m
+
hookCall :: Document ()
hookCall = toXml False . XR.MethodCall (XR.MethodName "hook") . Just .
XR.Params . map stringParam $