mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 19:42:50 -06:00
GFServer.hs: apply UTF8 decoding to all server input
This commit is contained in:
@@ -94,8 +94,8 @@ handle_fcgi execute1 state0 stateM cache =
|
|||||||
handle state0 cache execute1
|
handle state0 cache execute1
|
||||||
rq@(Request method URI{uriPath=upath,uriQuery=q} hdrs body) state =
|
rq@(Request method URI{uriPath=upath,uriQuery=q} hdrs body) state =
|
||||||
case method of
|
case method of
|
||||||
"POST" -> normal_request (inputs body)
|
"POST" -> normal_request (utf8inputs body)
|
||||||
"GET" -> normal_request (inputs q)
|
"GET" -> normal_request (utf8inputs q)
|
||||||
_ -> return (state,resp501 $ "method "++method)
|
_ -> return (state,resp501 $ "method "++method)
|
||||||
where
|
where
|
||||||
normal_request qs =
|
normal_request qs =
|
||||||
@@ -159,7 +159,7 @@ handle state0 cache execute1
|
|||||||
return (state',ok200 output)
|
return (state',ok200 output)
|
||||||
|
|
||||||
parse qs =
|
parse qs =
|
||||||
return (state,json200 (makeObj(map(parseModule.apBoth decodeString) qs)))
|
return (state,json200 (makeObj(map parseModule qs)))
|
||||||
|
|
||||||
cloud dir cmd qs =
|
cloud dir cmd qs =
|
||||||
case cmd of
|
case cmd of
|
||||||
@@ -394,6 +394,7 @@ toHeader s = FCGI.HttpExtensionHeader s -- cheating a bit
|
|||||||
|
|
||||||
-- * misc utils
|
-- * misc utils
|
||||||
|
|
||||||
|
utf8inputs = mapBoth decodeString . inputs
|
||||||
|
|
||||||
inputs = queryToArguments . fixplus
|
inputs = queryToArguments . fixplus
|
||||||
where
|
where
|
||||||
@@ -402,6 +403,7 @@ inputs = queryToArguments . fixplus
|
|||||||
decode c = [c]
|
decode c = [c]
|
||||||
|
|
||||||
mapFst f xys = [(f x,y)|(x,y)<-xys]
|
mapFst f xys = [(f x,y)|(x,y)<-xys]
|
||||||
|
mapBoth = map . apBoth
|
||||||
apBoth f (x,y) = (f x,f y)
|
apBoth f (x,y) = (f x,f y)
|
||||||
|
|
||||||
prop n v = (n,showJSON v)
|
prop n v = (n,showJSON v)
|
||||||
|
|||||||
Reference in New Issue
Block a user