Modify

Opened 9 years ago

Closed 9 years ago

#12375 closed defect (fixed)

Unicode character in ticket summary broken decoding in timeline

Reported by: massimo.b@… Owned by: falkb
Priority: normal Component: SimpleMultiProjectPlugin
Severity: normal Keywords:
Cc: Trac Release: 1.0

Description

As described in http://trac.edgewall.org/ticket/12092#comment:8...

SimpleMultiProjectPlugin is breaking the unicode decoding of the timeline view. Using '&' in ticket summaries results in '&' in the timeline.

This is trac 1.0.5 and SimpleMultiProject svn trunk.

Attachments (1)

ticket-summary.png (10.6 KB) - added by falkb 9 years ago.

Download all attachments as: .zip

Change History (18)

comment:1 Changed 9 years ago by anonymous

Is this a new effect or does it happen since a certain revision?

comment:2 Changed 9 years ago by massimo.b@…

Sorry, I never used a '&' character before in some summary. The original ticket already described the part of MultiProjectPlugin doing the wrong (?) decoding: simplemultiprojectplugin/trunk/simplemultiproject/timeline.py@14000:96#L86

comment:3 Changed 9 years ago by falkb

Thanks for the hint. I think I can reproduce it. Though need to find the time for debugging and fixing. I remember that puzzle was quite tricky there. If someone is faster than me, I'll appreciate the patch.

comment:4 Changed 9 years ago by falkb

Status: newaccepted

Please, could you try this patch and report back?:

  • timeline.py

     
    88from trac.ticket.model import Ticket
    99from simplemultiproject.model import *
    1010from trac.util.text import to_unicode
     11from trac.util.html import unescape
    1112from trac.core import *
    1213from trac.web.api import IRequestFilter, ITemplateStreamFilter
    1314from operator import itemgetter
     
    9899                ticket_no = splitted_output[0].split('>')
    99100                if len(tooltip) == 3: #it's a ticket
    100101                    #now rebuild the puzzle by inserting the name
    101                     output = tag('Ticket' + ' ', tag.em(ticket_no[1], title=tooltip[1]), ' ', tag.span(self._current_project[self._read_idx], style="background-color: #ffffd0;"), splitted_output[1])
     102                    output = tag('Ticket' + ' ', tag.em(ticket_no[1], title=tooltip[1]), ' ', tag.span(self._current_project[self._read_idx], style="background-color: #ffffd0;"), unescape(splitted_output[1]))
    102103                elif len(tooltip) == 1 and len(splitted_output) == 3: #it's an attachment
    103104                    output += tag(' ', tag.span(self._current_project[self._read_idx], style="background-color: #ffffd0;"))
    104105            return output

comment:5 Changed 9 years ago by massimo.b@…

No, that did not help. The splitted_output seems to already have the wrong encoding.

comment:6 Changed 9 years ago by falkb

I'm just thinking, not at the test bench at the moment. What about this?: splitted_output = unescape(to_unicode(output)).split("</em>")

comment:7 Changed 9 years ago by massimo.b@…

No. I also tried some mutations of to_unicode and unescape, but it did not help.

Changed 9 years ago by falkb

Attachment: ticket-summary.png added

comment:8 Changed 9 years ago by falkb

Hmmm, now I got access to the test bench and my second patch (comment:6) works well for me. See

comment:9 Changed 9 years ago by falkb

Did you really restart the webserver with the new plugin version? Otherwise I need such "bad" ticket summary for testing.

comment:10 Changed 9 years ago by massimo.b@…

While being new to Trac development, I'm sure I reloaded the plugin. Writing some

output = tag('FOO-Ticket' + ' ',

rebuilding the egg, copy to the ./plugins folder and restarting the uWSGI processes (not the webserver) results in the FOO-Ticket in the timeline.

Currently I have that state:

  • simplemultiproject/timeline.py

    old new  
    88from trac.ticket.model import Ticket
    99from simplemultiproject.model import *
    1010from trac.util.text import to_unicode
     11from trac.util.html import unescape
    1112from trac.core import *
    1213from trac.web.api import IRequestFilter, ITemplateStreamFilter
    1314from operator import itemgetter
     
    9394   
    9495            if field == 'title': #now it's time to insert the project name
    9596                #split the whole string until we can insert
    96                 splitted_output = to_unicode(output).split("</em>")
     97                splitted_output = unescape(to_unicode(output).split("</em>"))
    9798                tooltip = splitted_output[0].split('\"')
    9899                ticket_no = splitted_output[0].split('>')
    99100                if len(tooltip) == 3: #it's a ticket

I also tried a combination of the 2 patches.

I still have 'test & unicode testing' as summary in the ticket and 'test &amp; unicode testing)' in the timeline.

comment:11 Changed 9 years ago by falkb

Hi Massimo, please test this one (based on the SVN version):

  • timeline.py

     
    88from trac.ticket.model import Ticket
    99from simplemultiproject.model import *
    1010from trac.util.text import to_unicode
     11from trac.util.html import Markup, unescape
    1112from trac.core import *
    1213from trac.web.api import IRequestFilter, ITemplateStreamFilter
    1314from operator import itemgetter
     
    9899                ticket_no = splitted_output[0].split('>')
    99100                if len(tooltip) == 3: #it's a ticket
    100101                    #now rebuild the puzzle by inserting the name
    101                     output = tag('Ticket' + ' ', tag.em(ticket_no[1], title=tooltip[1]), ' ', tag.span(self._current_project[self._read_idx], style="background-color: #ffffd0;"), splitted_output[1])
     102                    ticket_summary = unescape(Markup(tooltip[1]))
     103                    msg_text = unescape(Markup(splitted_output[1]))
     104                    proj = self._current_project[self._read_idx]
     105                    output = tag('Ticket' + ' ', tag.em(ticket_no[1], title=ticket_summary), ' ', tag.span(proj, style="background-color: #ffffd0;"), msg_text)
    102106                elif len(tooltip) == 1 and len(splitted_output) == 3: #it's an attachment
    103107                    output += tag(' ', tag.span(self._current_project[self._read_idx], style="background-color: #ffffd0;"))
    104108            return output

comment:12 Changed 9 years ago by massimo.b@…

Yes, that fixed it, thanks. Please note when svn is fixed.

comment:13 Changed 9 years ago by falkb

In 14624:

see #12375 fixed rendering of special chars in ticket summary

comment:14 Changed 9 years ago by falkb

Keywords: testing added

comment:15 in reply to:  13 Changed 9 years ago by massimo.b@…

Replying to falkb:

In 14624: ...


I updated/reverted, tested successfully.

comment:16 Changed 9 years ago by falkb

Thanks. The same here. I keep it open for a general testing period to see if people see issues with this change. Will close it in about 3 weeks.

comment:17 Changed 9 years ago by falkb

Keywords: testing removed
Resolution: fixed
Status: acceptedclosed

Testing period over. No issues in a running production system.

Modify Ticket

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