[Zope-dev] Zope-Bug affecting my url_quoting (bug in getattr?)

Jan-Oliver Wagner jan@intevation.de
Tue, 7 Aug 2001 15:16:20 +0200


Hi all,

I just detected a serious bug:
(in short: to my mind getattr() behaves wrong)

http://freegis.org/details.en.html?name=Geoprocessamento%3a%20Teoria%20e%20Aplica%e7%f5es

was produced using <dtml-var name urlquote>.

(for those who don't have a browser at hand:
the attribute is converted back to
Geoprocessamento: Teoria e Aplicaēdetails.en.html5es
which is obviously wrong)

Manually using capital letters for the url quoting will work (ie. here
just '%F5es' at the end of the above URL.

Apparantly the %f is substituted by someone by the filename
(getattr already delivers this error).

Here is the code of details.en.html:

---------
<dtml-var standard_html_header>
<dtml-call "unquote()">
<dtml-if "_.hasattr(REQUEST, 'name')">
	<dtml-var entry_detailed>
<dtml-else>
	Error: there was no name given.
</dtml-if>
<dtml-var standard_html_footer>
---------

And here is unquote() [a python extension]:

---------
from urllib import *

def unquote_name(self):
	request = getattr(self, 'REQUEST')
	if hasattr(request, 'name'):
		name = getattr(request, 'name')
		# name already now contains the "%f" substituted by
		# "details.en.html"!!!
		request.set('name', unquote(name))
	return ''
---------

And here is the beginning of entry_detailed:

---------
<dtml-with REQUEST>

<h2>FreeGIS-summary on <dtml-var name></h2>
[...]
---------


-- 
Jan-Oliver Wagner               http://intevation.de/~jan/

Intevation GmbH	              	     http://intevation.de/
FreeGIS	                               http://freegis.org/