Modify

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#12405 closed defect (fixed)

Use of lstrip("field-") to attempt to remove the substring "field-" from front of string is erroneous

Reported by: gpoveda@… Owned by: Richard Liao
Priority: highest Component: TracTicketChainedFieldsPlugin
Severity: major Keywords:
Cc: Trac Release:

Description

In the file web_ui.py on line 177 the code is:

trigger = req.args.get("trigger", "").lstrip("field-")

The intent here is to "strip" off the substring "field-" from the beginning of the "trigger" request argument value. However, what this call actually does is strip off any of the characters in the set 'f', 'i', 'e', 'l', 'd', and '-' from the beginning of the string until a character is encountered that is NOT in the set. Therefore, if the trigger field name begins with any of these characters in the set, those characters will also be stripped off. Eg. a field named 'location' will be passed as trigger 'field-location', but after the lstrip call, trigger is set to 'ocation' instead. So any fields whose names begin with the characters in the set will fail to work as a chained field.

Attachments (0)

Change History (4)

comment:1 Changed 9 years ago by anonymous

Perhaps something like the following will be more appropriate:

trigger = req.args.get("trigger", "").replace('field-','',1)

comment:2 Changed 9 years ago by Ryan J Ollos

Resolution: fixed
Status: newclosed

In 14691:

0.2dev: Properly left strip field- token. Fixes #12405.

comment:3 Changed 9 years ago by Ryan J Ollos

I didn't have time to do any testing. Could you please confirm the fix?

comment:4 in reply to:  3 Changed 9 years ago by gpoveda@…

Replying to rjollos:

I didn't have time to do any testing. Could you please confirm the fix?

This fix is working fine for me. Thanks for the quick turn around!

Modify Ticket

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