(Video materials in preparation)
cgi-name : Converts data received using the CGI POST method
to "name" format.
Usage : cgi-name [<param_file>]
Options : --template <html>
-e<c>
-s<c>
-n<string>
Version : Tue Jan 9 09:02:34 JST 2024
Edition : 1
cgi-name converts data received using the web server CGI POST
method to "name" format.
Convert a string passed by the web server as 'place=tokyo&country=japan'
to the "Variable Value" format.
$ echo 'place=tokyo&country=japan' | cgi-name
place tokyo
country japan
Newlines (%0D%0A %0D %0A) are converted to "\n".
$ echo 'place=Tokyo%0D%0AOsaka&country=japan' | cgi-name
place Tokyo\nOsaka
country japan
The "-s" option deletes the space character or converts it
to a specified character.
$ echo 'place=tokyo osaka&country=japan' | cgi-name
place tokyo osaka
country japan
$ echo 'place=tokyo osaka&country=japan' | cgi-name -s_
place tokyo_osaka
country japan
$ echo 'place=tokyo osaka&country=japan' | cgi-name -s
place tokyoosaka
country japan
The "-e" option specifies a character to be escaped (prepended
with "\")
In this case '\' (%5C) becomes '\\'.
By combining with the "-s" option you can convert
'_' to '\_', '\' to '\\' or ' ' to '_'.
$ echo 'place=tokyo_osaka&country=japan' | cgi-name -e_
place tokyo\_osaka
country japan
$ echo 'place=tokyo%5Cosaka&country=j_a_p_a_n' | cgi-name -e_
place tokyo\\osaka
country j\_a\_p\_a\_n
$ echo 'place=tokyo osaka&country=j_a_p_a_n' | cgi-name -e_ -s_
place tokyo_osaka
country j\_a\_p\_a\_n
The "-n" option sets a default value to be used if the passed
value is null.
$ echo 'place=&country=japan' | cgi-name
place
country japan
$ echo 'place=&country=japan' | cgi-name -n somewhere
place somewhere
country japan
The "--template" option reads the names of radiobox and
checkbox elements, and if the names are not passed with
the data, it adds the names to the data.
If a form is submitted when radiobox or checkbox elements
have no selection, the element names are not passed. This
option makes it clear that no selection was made.
$ cat html
<input type="radio" name="XXXX" value="A" />
<input type="radio" name="XXXX" value="B" />
<input type="radio" name="XXXX" value="C" />
<input type="checkbox" name="YYYY" value="a" />
<input type="checkbox" name="YYYY" value="b" />
<input type="checkbox" name="YYYY" value="c" />
$ echo 'XXXX=abcd' | cgi-name -n_ --template html
XXXX abcd
YYYY _
YYYY _
YYYY _
Even if the radiobox or checkbox element is in the part
of the html template that is used by the strmerge-l command,
"TagName_%Value" is recognized so the tag name is output
even if no selection has been made.
$ cat html
<!-- MOJIHAME -->
<input type="radio" name="X_%1" value="%2" />
<input type="checkbox" name="Y_%1" value="%2" />
<!-- MOJIHAME -->
$ echo 'X_10=abcd' | cgi-name -n_ --template html
X_10 abcd
Y _
There are no newlines in the data passed using the CGI POST
metnod. To use as a normal file, it is best to add a newline
code at the end of the file. The cgi-name command can read
the values whether the file has a newline at the end or not.
Deprecated -d option (current -s option) is not supported.
Deprecated -i option (current -n option) is not supported.