SWUTILS-901: Avoid regex on uninitialized value#46
Conversation
|
|
||
| sub html_encode { | ||
| my $result = shift; | ||
| return '' unless defined $result; |
There was a problem hiding this comment.
Wouldn't this silently fail if html_encode is not passed an argument or the argument itself is undefined? If that were the case, I'd prefer the warning "Use of uninitialized value $result in substitution," which would help resolve the inconsistency sooner.
| @@ -308,6 +308,7 @@ sub pairs { | |||
|
|
|||
| sub html_encode { | |||
| my $result = shift; | |||
There was a problem hiding this comment.
Perl has had the // defined-or operator for quite a while now. I think it should be in RHEL6 even:
my $result = shift // '';
I've got an idea. How about having a section in the report (which doesn't appear at all if it has no contents) entitled something like 'sfreport internal diagnostics', where you can log unexpected events to help with debugging sfreport itself? Then you could use |
Some users report:
This is artificially reproduced when calling
print_textsub on a an uninitialized value. We were unable to determine what command resulted in this being the case in the field, but this patch makes sfreport more robust.