在我的html中,我有以下表格:
<form method=GET action="/cgi-bin/encry.sh">
<table nowrap>
<tr>
<td>Plain Text:</TD>
<TD><input type="text" name="PlainText"></td>
</tr>
</table>
<input type="submit" value="Encrypt">
</form>输入"aaa +=“并单击cgi-bin/encry.sh中的按钮后,QUERY_STRING被指定为"aaa++=”,而不是"aaa +=“或"a+%2B%3D”。这是正确的行为吗?如果是的话,我如何才能正确地获得空白呢?如果没有,是否在以后的CGIHTTPServer版本中修正了?
下面在我的CGIHTTPServer.py 7.2中提供了一些关于CentOS的信息:
HiAccount-4# md5sum /usr/lib64/python2.7/CGIHTTPServer.py
564afe4defc63001f236b0b2ef899b58 /usr/lib64/python2.7/CGIHTTPServer.py
HiAccount-4# grep __version /usr/lib64/python2.7/CGIHTTPServer.py -i
__version__ = "0.4"
HiAccount-4# grep unquote /usr/lib64/python2.7/CGIHTTPServer.py -i -C 3 -n
84- path begins with one of the strings in self.cgi_directories
85- (and the next character is a '/' or the end of the string).
86- """
87: collapsed_path = _url_collapse_path(urllib.unquote(self.path))
88- dir_sep = collapsed_path.find('/', 1)
89- head, tail = collapsed_path[:dir_sep], collapsed_path[dir_sep+1:]
90- if head in self.cgi_directories:
--
164- env['SERVER_PROTOCOL'] = self.protocol_version
165- env['SERVER_PORT'] = str(self.server.server_port)
166- env['REQUEST_METHOD'] = self.command
167: uqrest = urllib.unquote(rest)
168- env['PATH_INFO'] = uqrest
169- env['PATH_TRANSLATED'] = self.translate_path(uqrest)
170- env['SCRIPT_NAME'] = scriptname提前感谢!
发布于 2021-12-25 04:51:35
在尝试python2.7.18中的CGIHTTPServer之后,我认为所问的问题在2.7.5中是一个已知的问题,这是我的版本,并且不确定是哪个版本修复了它。
问题在于:
_url_collapse_path(urllib.unquote(self.path)) /
/usr/lib64 64/python2.7/CGIHTTPServer.py: 87: collapsed_path =
在2.7.18中,QUERY_STRING不是由CGIHTTPServer解码的,我需要用CGI脚本来解码它,但这没什么,因为它是“正确的”编码的QUERY_STRING。
顺便说一句,我没有将操作系统中的python从2.7.5升级到2.7.18,而是从python2.7.18源代码中提取CGIHTTPServer,并将其用作:
nohup ./CGIHTTPServer.py 7070 &
而不是
nohup python -m CGIHTTPServer 7070 &
https://stackoverflow.com/questions/69504746
复制相似问题