#3011: Trac crash on bad text on a comment of a changeset.
---------------------------------+------------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: cboos
Type: defect | Status: assigned
Priority: normal | Milestone: 0.10
Component: ticket system | Version: 0.9.4
Severity: normal | Resolution:
Keywords: |
---------------------------------+------------------------------------------
Changes (by cboos):
* status: new => assigned
* owner: jonas => cboos
* milestone: => 0.10
* component: general => ticket system
Comment:
Well, yes, there shouldn't be an exception in this situation.
{{{
Index: api.py
===================================================================
--- api.py (revision 3118)
+++ api.py (working copy)
@@ -160,17 +160,20 @@
fullmatch)
if intertrac:
return intertrac
- cursor = formatter.db.cursor()
- cursor.execute("SELECT summary,status FROM ticket WHERE id=%s",
- (target,))
- row = cursor.fetchone()
- if row:
- return html.A(class_='%s ticket' % row[1],
- title=shorten_line(row[0]) + ' (%s)' % row[1],
- href=formatter.href.ticket(target))[label]
- else:
- return html.A(class_='missing ticket', rel='nofollow',
- href=formatter.href.ticket(target))[label]
+ try:
+ target = int(target.lstrip('#'))
+ cursor = formatter.db.cursor()
+ cursor.execute("SELECT summary,status FROM ticket WHERE
id=%s",
+ (str(target),))
+ row = cursor.fetchone()
+ if row:
+ return html.A(class_='%s ticket' % row[1],
+ title=shorten_line(row[0]) + ' (%s)' %
row[1],
+ href=formatter.href.ticket(target))[label]
+ except ValueError:
+ pass
+ return html.A(class_='missing ticket', rel='nofollow',
+ href=formatter.href.ticket(target))[label]
# ISearchSource methods
}}}
This does two things:
* tolerate `ticket:#123` to be an alias for `ticket:123`
* create a missing ticket link when target is not a number or a '#'
followed by a number
--
Ticket URL: <http://projects.edgewall.com/trac/ticket/3011>
The Trac Project <http://trac.edgewall.com/>
_______________________________________________
Trac-Tickets mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac-tickets