Modify

Opened 3 years ago

Closed 22 months ago

Last modified 22 months ago

#11481 closed defect (fixed)

Browsing debug data nodes generates "Can't send unicode data" error with genshi-0.7

Reported by: lkraav Owned by: Jun Omae
Priority: normal Component: TracDeveloperPlugin
Severity: normal Keywords:
Cc: Ryan J Ollos Trac Release:

Description

Any other details needed?

Downgrading to 0.6 makes it work again.

See trac:#10126

Attachments (0)

Change History (11)

comment:1 Changed 3 years ago by Olemis Lang

yes, please ... Trac release ?

comment:2 Changed 3 years ago by lkraav

Hmm, trunk but I haven't pulled for a while now.

62b5507 - (origin/trunk, trunk) Merge r11675 from 1.0-stable (#11045) (11 months ago) <cboos>
Last edited 3 years ago by Ryan J Ollos (previous) (diff)

comment:3 Changed 3 years ago by lkraav

This is definitely happening on latest 1.1.2b1 trunk right now.

comment:4 Changed 3 years ago by lkraav

I'm running tracd btw.

comment:5 Changed 3 years ago by lkraav

Same fix needed as [14006]

comment:6 Changed 3 years ago by Jun Omae

I think we should just return template with data from process_request rather than rendering a template in the method. Trac core works well with both Genshi 0.6.x and 0.7.0.

  • tracdeveloperplugin/trunk/tracdeveloper/debugger.py

    diff --git a/tracdeveloperplugin/trunk/tracdeveloper/debugger.py b/tracdeveloperplugin/trunk/tracdeveloper/debugger.py
    index 94ed106..1f8a7a6 100644
    a b class TemplateDebugger(Component): 
    8686        key = token + ':' + path.split(':', 1)[0]
    8787        data = self._cache.get(key)
    8888        if not data:
    89             raise HTTPNotFound()
     89            raise HTTPNotFound("Not found '%s'" % path)
    9090        node = data.lookup(path)
    9191        data = {'node': node, 'drillable': self._is_drillable(req)}
    92         output = Chrome(self.env).render_template(req, 'developer/debug_node.html',
    93                                                   data, fragment=True)
    94         req.send(output.render('xhtml'), 'text/html')
     92        return 'developer/debug_node.html', data, None
    9593
    9694    # Internal methods
    9795

comment:7 Changed 3 years ago by Jun Omae

Also, I think TemplateDebugger component must check whether a user has TRAC_DEVELOP permission.

  • tracdeveloperplugin/trunk/tracdeveloper/debugger.py

    diff --git a/tracdeveloperplugin/trunk/tracdeveloper/debugger.py b/tracdeveloperplugin/trunk/tracdeveloper/debugger.py
    index 94ed106..194d823 100644
    a b class TemplateDebugger(Component): 
    2828        return handler
    2929
    3030    def post_process_request(self, req, template, data, content_type):
    31         if 'debug' not in req.args:
     31        if 'debug' not in req.args or 'TRAC_DEVELOP' not in req.perm:
    3232            return template, data, content_type
    3333
    3434        # Purge outdated debug info from cache
    class TemplateDebugger(Component): 
    6767    # IRequestHandler methods
    6868
    6969    def match_request(self, req):
    70         match = re.match(r'/developer/debug(?:/(.*))?$', req.path_info)
    71         if match:
    72             req.args['path'] = match.group(1)
    73             return True
     70        if 'TRAC_DEVELOP' in req.perm:
     71            match = re.match(r'/developer/debug(?:/(.*))?$', req.path_info)
     72            if match:
     73                req.args['path'] = match.group(1)
     74                return True
    7475
    7576    def process_request(self, req):
    7677        header = req.get_header('X-Requested-With')

comment:8 Changed 2 years ago by Ryan J Ollos

Cc: Ryan J Ollos added; anonymous removed

comment:9 Changed 22 months ago by Ryan J Ollos

Resolution: fixed
Status: newclosed

In 14628:

0.3.0dev: Fix error browsing debugger parameters.

"Can't send unicode data" error was seen with Genshi 0.7. Return template with data rather than rendering template in post_process_request. Fixes #11481.

Patch by Jun Omae.

comment:10 Changed 22 months ago by Ryan J Ollos

In 14629:

0.3.0dev: Require TRAC_DEVELOP to view debug data.

Patch by Jun Omae. Refs #11481.

comment:11 Changed 22 months ago by Ryan J Ollos

Owner: changed from Olemis Lang to Jun Omae

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
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.