Opened 3 years ago

Last modified 3 years 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 <>, user2 <> 

rather than the expected,

Account Name Email Last Login
user1 User One 16 hours ago
user2 User Two

Attachments (0)

Change History (4)

comment:1 Changed 3 years ago by rjollos

  • Description modified (diff)

comment:2 Changed 3 years ago by rjollos

Here is what I have in mind: Implement a _parse_args function in acctmgr.macros that calls 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 3 years ago by hasienda

  • Cc osimons jun66j5 added; anonymous removed
  • 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 3 years 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

as new The owner will remain hasienda.

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

Note: See TracTickets for help on using tickets.