From cbe46baae2862d9fbff66730a5ade936fa009637 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 6 Jul 2010 00:55:36 -0400 Subject: [PATCH] urls.encoding: tweak assoc>query to fix problem with OAuth --- basis/urls/encoding/encoding-tests.factor | 8 ++++++++ basis/urls/encoding/encoding.factor | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/basis/urls/encoding/encoding-tests.factor b/basis/urls/encoding/encoding-tests.factor index f3e0497588..84e6eaa890 100644 --- a/basis/urls/encoding/encoding-tests.factor +++ b/basis/urls/encoding/encoding-tests.factor @@ -11,6 +11,12 @@ USING: urls.encoding tools.test arrays kernel assocs present accessors ; [ "hello world" ] [ "hello world%x" url-decode ] unit-test [ "hello%20world" ] [ "hello world" url-encode ] unit-test +[ "~foo" ] [ "~foo" url-encode ] unit-test +[ "~foo" ] [ "~foo" url-encode-full ] unit-test + +[ ":foo" ] [ ":foo" url-encode ] unit-test +[ "%3Afoo" ] [ ":foo" url-encode-full ] unit-test + [ "hello world" ] [ "hello+world" query-decode ] unit-test [ "\u001234hi\u002045" ] [ "\u001234hi\u002045" url-encode url-decode ] unit-test @@ -25,6 +31,8 @@ USING: urls.encoding tools.test arrays kernel assocs present accessors ; [ H{ { "text" "hello world" } } ] [ "text=hello+world" query>assoc ] unit-test +[ "foo=%3A" ] [ { { "foo" ":" } } assoc>query ] unit-test + [ "a=3" ] [ { { "a" 3 } } assoc>query ] unit-test [ "a" ] [ { { "a" f } } assoc>query ] unit-test diff --git a/basis/urls/encoding/encoding.factor b/basis/urls/encoding/encoding.factor index f87c21d2ff..b035670614 100644 --- a/basis/urls/encoding/encoding.factor +++ b/basis/urls/encoding/encoding.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel ascii combinators combinators.short-circuit sequences splitting fry namespaces make assocs arrays strings @@ -11,7 +11,7 @@ IN: urls.encoding [ letter? ] [ LETTER? ] [ digit? ] - [ "/_-.:" member? ] + [ "-._~/:" member? ] } 1|| ; foldable ! see http://tools.ietf.org/html/rfc3986#section-2.2 @@ -120,7 +120,7 @@ PRIVATE> : assoc>query ( assoc -- str ) [ assoc-strings [ - [ url-encode ] dip - [ [ url-encode "=" glue , ] with each ] [ , ] if* + [ url-encode-full ] dip + [ [ url-encode-full "=" glue , ] with each ] [ , ] if* ] assoc-each ] { } make "&" join ;