Page MenuHomePhabricator

Add option to HTMLIntField that disallows plus/minus sign (unsigned, e.g. revision id)
Open, Needs TriagePublic

Description

The number for revision ids are unsigned int.

When using html form fields HTMLFloatField/HTMLIntField (or type=int/float) characters - and + are tolerated in the input.

To make this html form field suitable for taking a revision ID, there should be an option to forbid the signs so that -123 or +123 is rejected.

Using min = 0 is not the same as disallow the sign. Using + on oldid= in query is working, but not expected.

Event Timeline

Krinkle renamed this task from Allow 'unsigned' option on HTMLFloatField/HTMLIntField for numbers like revision ids to Add option to HTMLIntField that disallows plus/minus sign (unsigned, e.g. revision id).Jul 1 2020, 12:45 AM
Krinkle updated the task description. (Show Details)
Krinkle subscribed.

For the record:

Change 607874 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/core@master] Allow to select next/prev/cur on Special:Diff

https://gerrit.wikimedia.org/r/607874

This commit worksaround this limitation by using a Text field and a custom-made validation callback using preg_match( '/^\d*$/', $value ).

And perhaps, while at it, the same option could also disallow exponential notation. HTMLIntField accepts e.g. 1e2 and 1E3, but it's probably unwanted in some places.