ID:109826
 
Resolved
It was possible to paste non-numeric text into an "as num" input box by using the right-click menu.
BYOND Version:479
Operating System:Windows 7 Ultimate 64-bit
Web Browser:Chrome 10.0.648.82
Applies to:Dream Seeker
Status: Resolved (480)

This issue has been resolved.
Descriptive Problem Summary:
When an input is only supposed to take numerical input, you can 'right-click, paste' non-numerical stuff into it. CTRL-V however is properly disabled.

If you enter text in an input() via this method, it correctly gives a "Sorry, the following is not valid: text
usage: number" message. If you enter a 'Space' character however, it will accept the input.

If however it's as a parameter such as "mob/verb/test(N as num) it will still allow you to paste in any character - but it'll reopen the dialog repeatedly until you enter a number.

Numbered Steps to Reproduce Problem:
1. Get some text in your clipboard.
2. Open a dialog requiring 'as num' input.
3. Right-click the input box and select paste.
4. Click OK.

Code Snippet (if applicable) to Reproduce Problem:
/mob/verb/parameterMethod(N as num)
world << "-[N]-"
//Will output an error if you enter any non-number, and will repeat the dialog until you enter a number

/mob/verb/inputMethod()
var/N = input() as num
world << "-[N]-"
//Will output an error if you enter text, but will allow a space character(probably other special characters as well?) Does not repeat dialog.


Expected Results:
For neither dialog to allow non-numbers to be entered via right-click. If that's non-trivial to accomplish, I'd probably expect both inputs to behave the same way when they DO receive invalid data.

Actual Results:
Both allow non-numbers to be pasted in, and only the parameter version handles it as expected.

Does the problem occur:
Every time? Or how often? Every time.
In other games? Sure.
In other user accounts? Yep.
On other computers? Yes.

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
It also occurs in 478.

Workarounds:
Ensure you check your 'as num' input with isnum().