Fiexed bug: cannot escape request including multi-byte sequence correctly

This commit is contained in:
Hiromi Ishii 2011-06-21 03:10:16 +09:00
parent b06c4f5428
commit d9be899bf5

View File

@ -207,7 +207,7 @@ renderAuthHeader = ("OAuth " `BS.append`). BS.intercalate "," . map (\(a,b) -> B
paramEncode :: BS.ByteString -> BS.ByteString
paramEncode = BS.concatMap escape
where
escape c | isAlpha c || isDigit c || c `elem` "-._~" = BS.singleton c
escape c | isAscii c && (isAlpha c || isDigit c || c `elem` "-._~") = BS.singleton c
| otherwise = let num = map toUpper $ showHex (ord c) ""
oct = '%' : replicate (2 - length num) '0' ++ num
in BS.pack oct