[Zope-dev] Making Zope accept international characters in Id's

Andreas Jung andreas at andreas-jung.com
Mon Oct 20 10:22:02 EDT 2003


This issue has been discussed several times in the past. There was a 
consensus
not allow extended characters because of compatibility issues and 
conformance of
the HTTP specs (which don't allow extended chars in URLs AFAIk in unencoded 
form).
So it is your task to proof that your implementation works fine, does not 
break
compatibility and is compliant with the HTTP specs. I am not against using
extended chars (which would be fine) but there have not been any reasonable
approaches so far AFAIK.

-aj

--On Montag, 20. Oktober 2003 16:01 Uhr +0200 Lennart Regebro 
<lennart at regebro.nu> wrote:

> Hiya everyone!
>
> I didn't get any response on my last post, so I'm charging ahead full
> speed.
>
> The fact that litmus complains about Zope's inability to accept UTF-8
> filenames is something I view as a bug. It can be fixed simply by
> changing the default _checkid() implementation to allow extended
> characters. However, I don't want to break anything, so I think it should
> be optional, controlled by a setting.
>
> Either the already existing, but seemingly undocumented setting
> management_page_charset could be used to check that the given Id is
> acceptable in that charset.
>
> OR, a separate setting could be used, maybe allowed_id_charset?
>
>
> I'm gonna go with that last one if nobody complains. Suggested code (only
> the important parts):
>
>
># Any other characters that should NEVER be
># allowed?bad_id=re.compile(r'[:;/\\]').search
>
> def checkValidId(self, id, allow_dup=0):
>      # So should be allow unicode, then?
>      if not id or not isinstance(id, StringType):
>          if isinstance(id, UnicodeType): id = escape(id)
>          raise BadRequestException, ('Empty or invalid id specified', id)
>
>      # Here is the characterset checking. This works fine, I've tried it.
>      try:
>          charset = getattr(self, 'allowed_id_charset', 'ascii')
>          id.decode(charset)
>      except:
>          raise BadRequestException, (
>              'The id "%s" is not of the allowed character set (%s).' % \
>              (escape(id), self.allowed_id_charset))
>      # And here we check for unallowed special characters.
>      if bad_id(id) is not None:
>          raise BadRequestException, (
>              'The id "%s" contains characters illegal in URLs.' % \
>              escape(id))
>      # And then comes the rest of the tests, as usual, for aq_ and such.
>      # I won't copy them in in this mail.
>
>
> Opinions?
>
>
>
>
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev at zope.org
> http://mail.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists -  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope )







More information about the Zope-Dev mailing list