D 2019-06-13T05:39:27.315 J icomment Pulled\sthe\srelevant\scommits\sfrom\sthe\sclosed\sPR\sin.\r\n\r\n\r\nuse\s-nocase\sswitch\sin\sregsub\scommands\sto\smake\sregex\sshorter\s\r\n\r\n----\smodules/ncgi/ncgi.tcl\r\n@@\s-271,11\s+271,11\s@@\sproc\s::ncgi::decode\s{str}\s{\r\n\r\n\s\s\s\sset\sstr\s[string\smap\s[list\s+\s{\s}\s"\\\\"\s"\\\\\\\\"\s\\[\s\\\\\\[\s\\]\s\\\\\\]]\s$str]\r\n\r\n\s\s\s\s#\sprepare\sto\sprocess\sall\s%-escapes\r\n-\s\s\sregsub\s-all\s--\s{%([Ee][A-Fa-f0-9])%([89ABab][A-Fa-f0-9])%([89ABab][A-Fa-f0-9])}\s\\\r\n+\s\s\sregsub\s-all\s-nocase\s--\s{%([E][A-F0-9])%([89AB][A-F0-9])%([89AB][A-F0-9])}\s\\\r\n\t$str\s{[encoding\sconvertfrom\sutf-8\s[DecodeHex\s\\1\\2\\3]]}\sstr\r\n-\s\s\sregsub\s-all\s--\s{%([CDcd][A-Fa-f0-9])%([89ABab][A-Fa-f0-9])}\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\\\r\n+\s\s\sregsub\s-all\s-nocase\s--\s{%([CD][A-F0-9])%([89AB][A-F0-9])}\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\\\r\n\t$str\s{[encoding\sconvertfrom\sutf-8\s[DecodeHex\s\\1\\2]]}\sstr\r\n-\s\s\sregsub\s-all\s--\s{%([0-7][A-Fa-f0-9])}\s$str\s{\\\\u00\\1}\sstr\r\n+\s\s\sregsub\s-all\s-nocase\s--\s{%([0-7][A-F0-9])}\s$str\s{\\\\u00\\1}\sstr\r\n\r\n\s\s\s\s#\sprocess\s\\u\sunicode\smapped\schars\r\n\s\s\s\sreturn\s[subst\s-novar\s$str]\r\n----\r\nimproved\shandling\sof\sone\sbyte\sencodings\r\n\r\nIn\spractice\swww-url-encoded\sPOST\sparams\scan\suse\sencodings\sother\sthan\sUTF-8\r\n(think\sof\slegacy\sTcl\sapplications\sthat\suse\sone\sof\sthe\sISO-8859-x\scharsets).\sIn\r\nthis\scase\sURL\sparameters\scan\scontain\sreferences\sto\s8-bit\scode\spoints\s(in\sthe\r\nform\sof\s`%[A-F0-9][A-F0-9]`)\sthat\sare\snot\svalid\sUTF-8\scode\spoints.\r\n\r\nFor\sexample,\s`%DC`\scan\sbe\sused\sas\sa\spercent\sencoding\sfor\sthe\sgerman\sumlaut\s`Ü`\r\n(if\sa\sTcl\sapplication\sis\sbased\son\sISO-8859-1).\sCurrently,\sthe\s`decode`\r\nprocedure\sdoes\snot\sdecode\s`%DC`\sas\sall\sone\sbyte\sUTF-8\scode\spoints\smust\sstart\r\nwith\s`[0-7]`.\r\n\r\nThis\scommit\simproves\sthe\shandling\sof\sone\sbyte\spercent\sencoded\snon-ASCII\r\ncharacters.\sIt\sallows\sto\suse\sncgi\sin\sapplication\scontexts\sthat\sdo\snot\suse\r\nUTF-8\sas\sthe\sbase\sencoding.\r\n\r\n----\smodules/ncgi/ncgi.tcl\r\n@@\s-275,7\s+275,7\s@@\sproc\s::ncgi::decode\s{str}\s{\r\n\r\n\t$str\s{[encoding\sconvertfrom\sutf-8\s[DecodeHex\s\\1\\2\\3]]}\sstr\r\n\s\s\s\sregsub\s-all\s-nocase\s--\s{%([CD][A-F0-9])%([89AB][A-F0-9])}\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\\\r\n\t$str\s{[encoding\sconvertfrom\sutf-8\s[DecodeHex\s\\1\\2]]}\sstr\r\n-\s\s\sregsub\s-all\s-nocase\s--\s{%([0-7][A-F0-9])}\s$str\s{\\\\u00\\1}\sstr\r\n+\s\s\sregsub\s-all\s-nocase\s--\s{%([A-F0-9][A-F0-9])}\s$str\s{\\\\u00\\1}\sstr\r\n\r\n\s\s\s\s#\sprocess\s\\u\sunicode\smapped\schars\r\n\s\s\s\sreturn\s[subst\s-novar\s$str]\r\n---- J login aku J mimetype text/plain K 1f900bdf6bb6369987598e8c5f36a1e0f62b9798 U aku Z 5b611fa7697741bd81de9b917965a64e