From b97904c85f21bfb485f110b5b4f84abc5d6b0b66 Mon Sep 17 00:00:00 2001 From: Daniel Gnoutcheff Date: Wed, 15 Sep 2021 11:53:04 -0400 Subject: Unescape input messages --- app/Main.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'app') 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 $ -- cgit v1.2.3