From 7c376f213869209876e339fb66304c49f82aa363 Mon Sep 17 00:00:00 2001 From: defanor Date: Sun, 3 Feb 2019 23:50:16 +0300 Subject: Ignore duplicate parameters in XSLT Maybe query parameters should instead be passed to XSLTs as a part of the document to process, but perhaps better to ignore duplicate ones for now. --- Main.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Main.hs') diff --git a/Main.hs b/Main.hs index bfee6f3..49408ee 100644 --- a/Main.hs +++ b/Main.hs @@ -55,6 +55,7 @@ import Control.Arrow ((***)) import Control.Exception (bracket, finally, catches, Handler(..)) import System.FilePath (replaceExtension, takeFileName, ()) import System.Envy (decodeEnv, FromEnv(..), envMaybe, (.!=)) +import Data.List (nubBy) import Foreign import Foreign.C @@ -101,7 +102,8 @@ transform docBS baseStr pathStr stringParams = alloca $ \lenPtr -> bracket (notNull $ xmlReadMemory docCStr (fromIntegral docCStrLen) baseCStr nullPtr 0) xmlFreeDoc $ \doc -> - bracket (mapM newCString (concatMap (\(x, y) -> [x, y]) stringParams)) + bracket (mapM newCString (concatMap (\(x, y) -> [x, y]) $ + nubBy (\x y -> fst x == fst y) stringParams)) (mapM free) $ \params -> withArray0 nullPtr params $ \paramsArr -> withArray0 nullPtr [] $ \emptyArr -> -- cgit v1.2.3