Modify

Opened 16 months ago

Last modified 16 months ago

#11119 new enhancement

Strip whitespace from macro arguments

Reported by: rjollos Owned by: hasienda
Priority: normal Component: AccountManagerPlugin
Severity: normal Keywords: macro argument
Cc: osimons, jun66j5 Trac Release: 0.11

Description (last modified by rjollos)

While working on a patch t:#10751, I added a stripws argument to parse_args, to strip leading and trailing whitespace from macro arguments (see cd5f4cee). There hasn't been any interest expressed in the patch so far, but I encountered a situation this evening that made me think we should deal with this directly in the UserStats macro.

The macro call [[UserQuery(email, name, visit)]] results in the list [u'email', u' name', u' visit']. The output of the macro is then,

admin, user1 <user1@gmail.com>, user2 <user2@gmail.com> 

rather than the expected,

Account Name Email Last Login
admin
user1 User One user1@gmail.com 16 hours ago
user2 User Two user2@gmail.com

Attachments (0)

Change History (4)

comment:1 Changed 16 months ago by rjollos

  • Description modified (diff)

comment:2 Changed 16 months ago by rjollos

Here is what I have in mind: Implement a _parse_args function in acctmgr.macros that calls trac.wiki.api.parse_args and strips whitespace from the parameters. That way it will be easy to write a test case and the function can be reused if we end up with multiple classes in acct_mgr.macros later on.

comment:3 follow-up: Changed 16 months ago by hasienda

  • Cc osimons jun66j5 added
  • Keywords macro argument added
  • Trac Release set to 0.11

Sure, but I really wonder, why parse_args does not behave like that in the first place.

Something like parse_args(content, strip=true) comes in mind, if it should not be desired as default for whatever reason. I just can't think of a valid one right now, anyone else?

comment:4 in reply to: ↑ 3 Changed 16 months ago by rjollos

Replying to hasienda:

Sure, but I really wonder, why parse_args does not behave like that in the first place.

Same thoughts here. In the patch for Trac, I set the default to stripws=False for backward compatibility, but backward-compatibility considerations aside, I think stripws=True is a better default.

Most of the macros in Trac end up stripping whitespace after parse_args is called, for example TracIni macro.

Add Comment

Modify Ticket

Action
as new .
Author


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

 
Note: See TracTickets for help on using tickets.