telldus / tellstick-server-plugins

Plugins for TellStick Server
14 stars 8 forks source link

smtpServer length validation impossible to pass #12

Open edvarddrake opened 3 years ago

edvarddrake commented 3 years ago

In the mailsender plugin, this:
smtpServer = ConfigurationString( defaultValue='', title='SMTP server name', description='Address to the smtpserver', minLength=4

...causes the input validation in the browser to fail, as it allows only strings of "length between 4 and 0" as smtpServers. No change is possible to perform given this. By rewriting the validation code in the browser manually (using the developer mode in Chrome), I can work around it, so it is clear that the issue is that the browser validation is the problem. Just removing the length check makes it possible to send the update to the server.

My guess is that the server has been amended to actually generate some validation checking code for the browser based on "minLength = 4" , and that this has exposed the incorrect check in the plugin code. An earlier version of the server side probably did not create that check in the browser-side code at all. Which is why mailsender used to work (I know it did, since I used it)

EDIT: It should be noted that "minLength = 4" is faulty only if the generation of validation code requires a maxLength to be given as well, or else defaults 0. Unfortunately the validation code that results from the current plugin values does exactly that (i.e. it checks for "length between 4 and 0", which always fails, by definition). The solution can be to add a maxLength in the configuration dialog (and treat it correctly when turning it into validation code), OR if there is only minLength = 4 and no maxLength given, just check for "length between 4 and infinity" instead.