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;
|
if (!e.response || e.response === 'cancel') return;
|
||||||
try {
|
try {
|
||||||
var cfg = JSON.parse(decodeURIComponent(e.response));
|
var cfg = JSON.parse(decodeURIComponent(e.response));
|
||||||
localStorage.setItem('chunk', cfg.chunk);
|
var chunk = parseInt(cfg.chunk, 10);
|
||||||
localStorage.setItem('start', cfg.start);
|
var start = parseInt(cfg.start, 10);
|
||||||
localStorage.setItem('end', cfg.end);
|
var end = parseInt(cfg.end, 10);
|
||||||
sendConfig(cfg);
|
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) {
|
} catch (err) {
|
||||||
console.log('Failed to parse config: ' + err);
|
console.log('Failed to parse config: ' + err);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user