mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-22 03:34:14 +00:00
safeguard against NaN & null-value tasks
This commit is contained in:
parent
5d223d8546
commit
81f83be160
1 changed files with 6 additions and 0 deletions
|
|
@ -191,6 +191,12 @@ obj.score = (user, task, direction, options={}) ->
|
|||
[paths, times, cron] = [options.paths || {}, options.times || 1, options.cron || false]
|
||||
priority = task.priority or '!'
|
||||
|
||||
# Handle corrupt tasks
|
||||
return 0 unless task.id
|
||||
if !_.isNumber(value) or _.isNaN(value)
|
||||
task.value = value = 0;
|
||||
paths["task.#{task.id}.value"] = true
|
||||
|
||||
# If they're trying to purhcase a too-expensive reward, don't allow them to do that.
|
||||
if task.value > user.stats.gp and task.type is 'reward'
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in a new issue