From ebeb52212dcc04076dbe046af33c8b0ac53f6ad8 Mon Sep 17 00:00:00 2001 From: James Brechtel Date: Wed, 20 May 2026 14:46:43 -0400 Subject: [PATCH] fix: properly percent-decode URL-encoded form values in import The urldecode helper in parseFormBody was using Html.urlDecode which only handled %%20, %%23, and %%25. Full URLs encode colons, slashes, and dots as %%3A, %%2F, and %%2E, so they were never decoded. The scraper received the still-encoded URL and failed to fetch it. Replace Html.urlDecode with a proper percent-decode that handles all %%XX hex sequences using digitToInt. --- src/Roux/Server.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Roux/Server.hs b/src/Roux/Server.hs index 52db74b..8ba1412 100644 --- a/src/Roux/Server.hs +++ b/src/Roux/Server.hs @@ -17,7 +17,7 @@ import Control.Monad (forM_, forever, when) import Data.ByteString.Builder (lazyByteString) import Data.ByteString.Lazy (ByteString) import qualified Data.ByteString.Lazy as LB -import Data.Char (toLower) +import Data.Char (digitToInt, toLower) import Data.IORef (IORef, atomicModifyIORef', newIORef, readIORef, writeIORef) import Data.List (isSuffixOf) import Data.Map.Strict (Map) @@ -226,7 +226,13 @@ parseFormBody body = parsePair part = case T.splitOn "=" part of [key, val] -> Just (urldecode key, urldecode val) _ -> Nothing - urldecode = T.pack . Html.urlDecode . T.replace "+" " " + -- Proper percent-decode for all %XX sequences (not just %20/%23/%25). + urldecode = T.pack . go . T.unpack . T.replace "+" " " + go [] = [] + go ('%' : a : b : rest) = + let hexVal = digitToInt a * 16 + digitToInt b + in toEnum hexVal : go rest + go (c : rest) = c : go rest -- | Locate the scrape-recipe script: check PATH first, then relative to project. findScrapeScript :: IO FilePath