View Issue Details

IDProjectCategoryView StatusLast Update
0017156MMW 5Extensions frameworkpublic2020-12-06 15:38
Reporterdrakinite Assigned To 
PriorityurgentSeveritycrashReproducibilityalways
Status closedResolutionfixed 
Target Version5.0Fixed in Version5.0 
Summary0017156: Invalid addon config scripts cause crash
DescriptionWhen an addon's config script does not create a window.configInfo object with load() and save() functions, it causes a crash from dlgAddonConfig.js.

Ideally, dlgAddonConfig.js would catch the invalid code and display it to the user without a crash. Modified dlgAddonConfig attached.
TagsNo tags attached.
Attached Files
dlgAddonConfig.js (1,126 bytes)   
/* '(C) Ventis Media, Licensed under the Ventis Limited Reciprocal License - see: license.txt for details' */

"use strict";

function init(params) {
    var wnd = this;
    wnd.resizeable = true;

    assert(params.addon, 'params.addon not defined');
    var item = params.addon;

    wnd.title = _('Addon Configuration') + ' | ' + item.title;

    window.configInfo;
    requirejs(item.configFile);
    var panel = qid('pnlContent');
    
    if (typeof window.configInfo === 'object' && typeof window.configInfo.load === 'function' && typeof window.configInfo.save === 'function') {
        window.configInfo.load(panel, item);
    
        window.localListen(qid('btnOK'), 'click', function () {
            window.configInfo.save(panel, item);
            closeWindow();
        });
    }
    else {
        messageDlg(_('Invalid addon configuration file.') + '</br></br>' + _('window.configInfo must be defined, and window.configInfo.load and window.configInfo.save must be functions.'), 'Error', ['btnOk'], {defaultButton: 'btnOk'}, () => {
            closeWindow();
        });
    }
}
dlgAddonConfig.js (1,126 bytes)   
Fixed in build2278

Relationships

related to 0017176 newLudek Developer Mode: Addon scripts during testing should have default Developer mode 

Activities

Ludek

2020-12-03 14:17

developer   ~0060528

OK, I applied your changes -- just left the error message untranslated (i.e. removed the _() function in order to not get into our localization WebLate framework)
=> added in 2278

But note that generally we can hardly catch all errors in addons (it is not even possible as addon can modify any part of MM code), so addon developers should use the '[x] Developer mode' checkbox in Options > About to supress the script errors being submitted during development. And we will see the errors coming from users later to get the addon developer know that his script has a defect.

peke

2020-12-06 15:38

developer   ~0060578

Verified 2280

Works OK, no regressions.