Validate config values before storing and sending to watch
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -77,10 +77,17 @@ Pebble.addEventListener('webviewclosed', function(e) {
|
||||
if (!e.response || e.response === 'cancel') return;
|
||||
try {
|
||||
var cfg = JSON.parse(decodeURIComponent(e.response));
|
||||
localStorage.setItem('chunk', cfg.chunk);
|
||||
localStorage.setItem('start', cfg.start);
|
||||
localStorage.setItem('end', cfg.end);
|
||||
sendConfig(cfg);
|
||||
var chunk = parseInt(cfg.chunk, 10);
|
||||
var start = parseInt(cfg.start, 10);
|
||||
var end = parseInt(cfg.end, 10);
|
||||
if (chunk <= 0 || chunk > 60) return;
|
||||
if (start < 0 || start > 22) return;
|
||||
if (end < 1 || end > 23) return;
|
||||
if (start >= end) return;
|
||||
localStorage.setItem('chunk', chunk);
|
||||
localStorage.setItem('start', start);
|
||||
localStorage.setItem('end', end);
|
||||
sendConfig({ chunk: chunk, start: start, end: end });
|
||||
} catch (err) {
|
||||
console.log('Failed to parse config: ' + err);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user