qore
qore copied to clipboard
module-ssh2: SftpPoller doesn't accept empty string as regex_mask
(and fails not very transparently instead)
$ qore -n -l SftpPoller -e 'class MySftpPoller inherits SftpPoller {constructor(SFTPClient sftp, hash nconf): SftpPoller(sftp, nconf) {} postSingleFileEvent(hash fih) {} singleFileEvent(hash fih) {}} MySftpPoller a(new SFTPClient("sftp://localhost:22"), {"regex_mask": ""});'
unhandled QORE System exception thrown in TID 1 at 2019-04-16 13:14:11.973498 Tue +02:00 (CEST) in SftpPoller::constructor() (/usr/share/qore-modules/SftpPoller.qm:316 (Qore user code))
INVALID-MEMBER: 'regex_mask' is not a registered member of class 'MySftpPoller'
call stack:
2: SftpPoller::constructor() (<command-line>:1 (Qore user code))
1: MySftpPoller::constructor() (<command-line>:1 (Qore user code))
This is because of how SftpPoller accepts arguments, specifically for regex_mask
:
if (conf.regex_mask) {
mask = remove conf.regex_mask;
re = True;
conf -= "mask";
}
# set options
self += conf;
-> if regex_mask evaluates to False in bool context, SftpPoller considers it not being in the conf hash and doesn't remove it (but it is there) and then it fails when it tries to assign the rest of the hash to its' member variables.
bug for sure, but just wondering, what should the empty mask do?
Well, an empty string is a valid regex matching anything.