Tcl Library Source Code

Check-in [61a9c3db15]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:ncgi - Tkt [1f900bdf6b] - I Applied patch shortening a few regex pattern by making use of `-nocase` option for `regsub`. This is the first of two. Thanks to https://saschaszott.github.io/
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | ncgi-1f900bdf6b
Files: files | file ages | folders
SHA3-256: 61a9c3db158d600056a0684eaea1fdeafc6ab52b49e388c26632149043ec37ff
User & Date: andreask 2019-06-24 17:06:33.751
Context
2019-06-24
17:20
ncgi - Tkt [1f900bdf6b] - B, T Bumped to version 1.4.4. Regenerated docs. Applied patch to improvde handling of 1-byte encodings. This is the second of two. Thanks to https://saschaszott.github.io/ Updated test case ncgi-3.10. His explanation: In practice www-url-encoded POST params can use encodings other than UTF-8 (think of legacy Tcl applications that use one of the ISO-8859-x charsets). In this case URL parameters can contain references to 8-bit code points (in the form of `%[A-F0-9][A-F0-9]`) that are not valid UTF-8 code points. For example, `%DC` can be used as a percent encoding for the german umlaut `Ü` (if a Tcl application is based on ISO-8859-1). Currently, the `decode` procedure does not decode `%DC` as all one byte UTF-8 code points must start with `[0-7]`. This commit improves the handling of one byte percent encoded non-ASCII characters. It allows to use ncgi in application contexts that do not use UTF-8 as the base encoding. Closed-Leaf check-in: b65597a91b user: andreask tags: ncgi-1f900bdf6b
17:06
ncgi - Tkt [1f900bdf6b] - I Applied patch shortening a few regex pattern by making use of `-nocase` option for `regsub`. This is the first of two. Thanks to https://saschaszott.github.io/ check-in: 61a9c3db15 user: andreask tags: ncgi-1f900bdf6b
2019-06-21
05:07
Integrated work on the test assets into trunk. check-in: 23b8d4b98e user: aku tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to modules/ncgi/ncgi.tcl.
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285

proc ::ncgi::decode {str} {
    # rewrite "+" back to space
    # protect \ from quoting another '\'
    set str [string map [list + { } "\\" "\\\\" \[ \\\[ \] \\\]] $str]

    # prepare to process all %-escapes
    regsub -all -- {%([Ee][A-Fa-f0-9])%([89ABab][A-Fa-f0-9])%([89ABab][A-Fa-f0-9])} \
	$str {[encoding convertfrom utf-8 [DecodeHex \1\2\3]]} str
    regsub -all -- {%([CDcd][A-Fa-f0-9])%([89ABab][A-Fa-f0-9])}                     \
	$str {[encoding convertfrom utf-8 [DecodeHex \1\2]]} str
    regsub -all -- {%([0-7][A-Fa-f0-9])} $str {\\u00\1} str

    # process \u unicode mapped chars
    return [subst -novar $str]
}

# ::ncgi::encode
#







|

|

|







267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285

proc ::ncgi::decode {str} {
    # rewrite "+" back to space
    # protect \ from quoting another '\'
    set str [string map [list + { } "\\" "\\\\" \[ \\\[ \] \\\]] $str]

    # prepare to process all %-escapes
    regsub -all -nocase -- {%([E][A-F0-9])%([89AB][A-F0-9])%([89AB][A-F0-9])} \
	$str {[encoding convertfrom utf-8 [DecodeHex \1\2\3]]} str
    regsub -all -nocase -- {%([CDcd][A-F0-9])%([89AB][A-F0-9])} \
	$str {[encoding convertfrom utf-8 [DecodeHex \1\2]]} str
    regsub -all -nocase -- {%([0-7][A-F0-9])} $str {\\u00\1} str

    # process \u unicode mapped chars
    return [subst -novar $str]
}

# ::ncgi::encode
#