Page MenuHomePhabricator

Expand the allowed characters for variable insertable for translatable pages.
Open, Needs TriagePublic

Description

The tvar syntax allows custom names for variables, not only numbers. The syntax currently seems to allow pretty much anything except '>'. If non-numeric value is used, it won't be treated as an insertable.

I see a few options:

  • exclusion list: allow everything but a few special characters special in wikitext, punctuation and a space (for obvious reasons): \$[^"<>|:{}\[\].,?!]
  • allowed list: allow only ascii letters and numbers: \$[a-zA-Z0-9_-]
  • allow list: allow only letters and numbers, as defined by Unicode: \$[\p{LN}_-]

Event Timeline

If non-numeric value is used, it won't be treated as an insertable.

Letters A-Z, hyphens and underscore seems supported too (TranslatablePageInsertablesSuggester).

As you wrote, authorizing only ASCII is not friendly for not-latin-script.
Else, I think whitelist or blacklist will produce the same result, but using an exclusion list is probably better for flexibility.

Finally, what do you think about setting an optional ending character?
There are some cases where tvar joins alphanumeric characters, which produces a wrong insertable.
e.g. <tvar|tag><b></>text produces wrong $tagtext insertable.

With $ as an optional ending character, translation admin could workround this issue:
<tvar|tag$><b></>text would produce $tag$ insertable.