From 950078003767de36132f179ca00d8c81dbcc162a Mon Sep 17 00:00:00 2001 From: Araq Date: Wed, 10 Sep 2014 23:25:29 +0200 Subject: [PATCH] renamed URLencode to encodeUrl --- compiler/docgen.nim | 4 ++-- lib/pure/cgi.nim | 16 +++++++++------- todo.txt | 1 - 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/compiler/docgen.nim b/compiler/docgen.nim index c34332b57..273fcb7f3 100644 --- a/compiler/docgen.nim +++ b/compiler/docgen.nim @@ -374,11 +374,11 @@ proc genItem(d: PDoc, n, nameNode: PNode, k: TSymKind) = cleanPlainSymbol = renderPlainSymbolName(nameNode) complexSymbol = complexName(k, n, cleanPlainSymbol) plainSymbolRope = toRope(cleanPlainSymbol) - plainSymbolEncRope = toRope(urlEncode(cleanPlainSymbol)) + plainSymbolEncRope = toRope(encodeUrl(cleanPlainSymbol)) itemIDRope = toRope(d.id) symbolOrId = d.newUniquePlainSymbol(complexSymbol) symbolOrIdRope = symbolOrId.toRope - symbolOrIdEncRope = urlEncode(symbolOrId).toRope + symbolOrIdEncRope = encodeUrl(symbolOrId).toRope var seeSrcRope: PRope = nil let docItemSeeSrc = getConfigVar("doc.item.seesrc") diff --git a/lib/pure/cgi.nim b/lib/pure/cgi.nim index d5690bf51..e8977b80b 100644 --- a/lib/pure/cgi.nim +++ b/lib/pure/cgi.nim @@ -31,7 +31,7 @@ import strutils, os, strtabs, cookies -proc urlEncode*(s: string): string = +proc encodeUrl*(s: string): string = ## Encodes a value to be HTTP safe: This means that characters in the set ## ``{'A'..'Z', 'a'..'z', '0'..'9', '_'}`` are carried over to the result, ## a space is converted to ``'+'`` and every other character is encoded as @@ -52,7 +52,7 @@ proc handleHexChar(c: char, x: var int) {.inline.} = of 'A'..'F': x = (x shl 4) or (ord(c) - ord('A') + 10) else: assert(false) -proc urlDecode*(s: string): string = +proc decodeUrl*(s: string): string = ## Decodes a value from its HTTP representation: This means that a ``'+'`` ## is converted to a space, ``'%xx'`` (where ``xx`` denotes a hexadecimal ## value) is converted to the character with ordinal number ``xx``, and @@ -74,6 +74,8 @@ proc urlDecode*(s: string): string = inc(j) setLen(result, j) +{.deprecated: [URLDecode: decodeUrl, URLEncode: encodeUrl].} + proc addXmlChar(dest: var string, c: char) {.inline.} = case c of '&': add(dest, "&") @@ -100,7 +102,7 @@ type methodGet ## query uses the GET method {.deprecated: [TRequestMethod: RequestMethod, ECgi: CgiError, - URLencode: urlEncode, XMLencode: xmlEncode, URLdecode: urlDecode].} + XMLencode: xmlEncode].} proc cgiError*(msg: string) {.noreturn.} = ## raises an ECgi exception with message `msg`. @@ -332,9 +334,9 @@ proc setTestData*(keysvalues: varargs[string]) = var i = 0 var query = "" while i < keysvalues.len: - add(query, urlEncode(keysvalues[i])) + add(query, encodeUrl(keysvalues[i])) add(query, '=') - add(query, urlEncode(keysvalues[i+1])) + add(query, encodeUrl(keysvalues[i+1])) add(query, '&') inc(i, 2) putEnv("QUERY_STRING", query) @@ -394,5 +396,5 @@ proc existsCookie*(name: string): bool = when isMainModule: const test1 = "abc\L+def xyz" - assert URLencode(test1) == "abc%0A%2Bdef+xyz" - assert URLdecode(URLencode(test1)) == test1 + assert encodeUrl(test1) == "abc%0A%2Bdef+xyz" + assert decodeUrl(encodeUrl(test1)) == test1 diff --git a/todo.txt b/todo.txt index 2785e4d2e..66f47a1d8 100644 --- a/todo.txt +++ b/todo.txt @@ -3,7 +3,6 @@ version 0.10 - Test nimfix on various babel packages - Pegs do not work at compile-time -- rename cgi.URLencode to encodeUrl version 0.9.6