Skip to content

Commit cf91ebb

Browse files
committed
* (Apollon77) Handle more cases with invalid script names/state-ids (Sentry IOBROKER-JAVASCRIPT-5W)
1 parent 70d16b9 commit cf91ebb

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ And then call `npm run build`.
3838

3939
## Changelog
4040

41+
### __WORK IN PROGRESS__
42+
* (Apollon77) Handle more cases with invalid script names/state-ids (Sentry IOBROKER-JAVASCRIPT-5W)
43+
4144
### 4.10.14 (2021-01-25)
4245
* (Apollon77) Handle more cases with invalid script names/state-ids (Sentry IOBROKER-JAVASCRIPT-5R)
4346

main.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,11 +1701,13 @@ function prepareScript(obj, callback) {
17011701
if (obj && obj._id) {
17021702
_name = obj._id;
17031703
const scriptIdName = _name.substring('script.js.'.length);
1704-
if (scriptIdName.length) {
1705-
adapter.setState('scriptEnabled.' + scriptIdName, false, true);
1706-
} else {
1707-
adapter.log.error('Invalid scriptname');
1704+
1705+
if (!scriptIdName.length || scriptIdName.endsWith('.')) {
1706+
adapter.log.error(`Script name ${_name} is invalid!`);
1707+
typeof callback === 'function' && callback(false, _name);
1708+
return;
17081709
}
1710+
adapter.setState('scriptEnabled.' + scriptIdName, false, true);
17091711
}
17101712
!obj && adapter.log.error('Invalid script');
17111713
typeof callback === 'function' && callback(false, _name);

0 commit comments

Comments
 (0)