Modify

Opened 17 years ago

Closed 3 years ago

#2610 closed defect (wontfix)

problems with unicode chars

Reported by: haf@… Owned by:
Priority: normal Component: CacheSystemPlugin
Severity: major Keywords:
Cc: Trac Release: 0.10

Description

Using unicode chars, the feature does reply with an overall error (see below). In an existing page this is a show-stopper, because the error does not point to the page or char which is malicious. How can I find out which one is the bad unicode character to remove it eventually? Or could unicode support be added to the feature?

Trac[__init__] ERROR: Keys must be str()'s, notunicode.  Convert your unicode strings using  mystring.encode(charset)!
Traceback (most recent call last):
  File "/var/lib/python-support/python2.4/trac/web/main.py", line 387, in dispatch_request     dispatcher.dispatch(req)
  File "/var/lib/python-support/python2.4/trac/web/main.py", line 191, in dispatch     chosen_handler = self._pre_process_request(req, chosen_handler)
  File "/var/lib/python-support/python2.4/trac/web/main.py", line 263, in _pre_process_request     chosen_handler = f.pre_process_request(req, chosen_handler)
  File "build/bdist.linux-i686/egg/cachesystem/filter.py", line 40, in pre_process_request 
  File "/usr/lib/python2.4/site-packages/python_memcached-1.40-py2.4.egg/memcache.py", line 619,  in get check_key(key)
  File "/usr/lib/python2.4/site-packages/python_memcached-1.40-py2.4.egg/memcache.py", line 878, i n check_key raise Client.MemcachedStringEncodingError, ("Keys must be str()'s, not"
MemcachedStringEncodingError: Keys must be str()'s, notunicode.  Convert your unicode strings using mystring.encode(charset)!

Attachments (0)

Change History (4)

comment:1 Changed 17 years ago by anonymous

Component: TracHacksCacheSystemPlugin
Owner: changed from Alec Thomas to Noah Kantrowitz

comment:2 Changed 12 years ago by gonzalob@…

I had the same issue. Fixed it in a non-elegant way, but this ticket has 5 years open so that'll have to do.

  • filter.py

     
    3232   
    3333    # IRequestFilter methods
    3434    def pre_process_request(self, req, handler):
     35    key = req.path_info.encode('ascii')
    3536        if isinstance(handler, WikiModule):
    3637            if req.method == 'GET' and \
    3738               req.args.get('action', 'view') == 'view' and \
    3839               req.args.get('format') is None and \
    3940               req.args.get('version') is None:
    40                 page = self.client.get(req.path_info)
     41                page = self.client.get(key)
    4142                if page is not None:
    4243                    self.log.debug('CacheFilter: Cache hit on %s', req.path_info)
    4344                    req.__CACHED_PAGE = page
     
    4546                else:
    4647                    req.__PLEASE_CACHE = True
    4748            elif req.method == 'POST':
    48                 self.client.delete(req.path_info)
     49                self.client.delete(key)
    4950       
    5051        return handler
    5152       
    5253    def post_process_request(self, req, template, content_type):
    5354        try:
    5455            if req.__PLEASE_CACHE:
    55                 self.client.set(req.path_info, req.hdf.getObj('wiki').writeString(), self.timeout)
     56                self.client.set(req.path_info.encode('ascii'), req.hdf.getObj('wiki').writeString(), self.timeout)
    5657        except AttributeError:
    5758            pass
    5859        return template, content_type
     
    6970        req.hdf.copy('wiki', wiki_hdf.hdf)
    7071        return 'wiki.cs', None
    7172       
    72    
    73  No newline at end of file
     73   

comment:3 Changed 10 years ago by Ryan J Ollos

Owner: Noah Kantrowitz deleted

comment:4 Changed 3 years ago by Ryan J Ollos

Resolution: wontfix
Status: newclosed

Deprecated and removed.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.