This allows using newlines and quotes in error messages.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/lib/WineTestBot/CGI/PageBase.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/testbot/lib/WineTestBot/CGI/PageBase.pm b/testbot/lib/WineTestBot/CGI/PageBase.pm index 121e09aabd..5f61466908 100644 --- a/testbot/lib/WineTestBot/CGI/PageBase.pm +++ b/testbot/lib/WineTestBot/CGI/PageBase.pm @@ -360,8 +360,10 @@ sub GenerateErrorPopup($$) { print "<script type='text/javascript'>\n"; print "<!--\n"; - $ErrMessage =~ s/'/\'/g; - print "function ShowError() { alert('", $ErrMessage, "'); }\n"; + $ErrMessage =~ s~\~\\~g; + $ErrMessage =~ s~"~\"~g; + $ErrMessage =~ s~\n~\n~g; + print "function ShowError() { alert("$ErrMessage"); }\n"; my $ErrField = $Page->GetErrField(); if ($ErrField) {
Hiding errors related to hidden parameters causes actions to have no effect which is very confusing. So show these errors too but prefix them with text hinting they are likely internal errors.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- Note that the linefeed in the error message requires the previous patch for proper handling.
When I first added tables for the random failures blacklisting (bug 48912), clicking on the form's "Save" button had no effect whatsoever because this function was hiding the errors. The issue was some hidden fields had invalid default values, causing the database save to fail. This patch will make such issues trivial to diagnose. Should they happen in the wild they should also get us better bug reports. --- testbot/lib/ObjectModel/CGI/FormPage.pm | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/testbot/lib/ObjectModel/CGI/FormPage.pm b/testbot/lib/ObjectModel/CGI/FormPage.pm index 735755f3cf..0ac599e137 100644 --- a/testbot/lib/ObjectModel/CGI/FormPage.pm +++ b/testbot/lib/ObjectModel/CGI/FormPage.pm @@ -108,18 +108,17 @@ sub GenerateBody($) $self->GenerateFields(); $self->GenerateRequiredLegend();
- if (defined($self->{ErrMessage})) + if (defined $self->{ErrMessage}) { - my $PropertyDescriptor; - if (defined($self->{ErrField})) + if (defined $self->{ErrField}) { - $PropertyDescriptor = $self->GetPropertyDescriptorByName($self->{ErrField}); - } - if (! defined($PropertyDescriptor) || - $self->DisplayProperty($PropertyDescriptor)) - { - $self->GenerateErrorPopup(); + my $PropertyDescriptor = $self->GetPropertyDescriptorByName($self->{ErrField}); + if ($PropertyDescriptor and !$self->DisplayProperty($PropertyDescriptor)) + { + $self->{ErrMessage} = "Internal error?\n$self->{ErrMessage}"; + } } + $self->GenerateErrorPopup(); } $self->GenerateActions(); $self->GenerateFormEnd();