List Info

Thread: Code select verification patch




Code select verification patch
user name
2008-03-20 11:13:34
Here's the preemptive patch before Dawn files a bug report.
It uses  
the handy eval_codeselect function in Bric::App::Util to
perform  
validation rather than have its own set of rules.

Once you already have a code select and then go in to edit
it, you can  
then put invalid code and it still lets you save. Once you
notice the  
resulting code select is empty and you go in to edit again,
the  
add_msg red warning ("Invalid code select...")
shows up at that point.  
Not sure if this is a bug or a feature but the attached
patch doesn't  
deal with this part.


Index: lib/Bric/App/Callback/Profile/FormBuilder.pm
============================================================
=======
--- lib/Bric/App/Callback/Profile/FormBuilder.pm	(revision
8043)
+++ lib/Bric/App/Callback/Profile/FormBuilder.pm	(working
copy)
 -8,7
+8,7 
  use Bric::App::Authz qw(:all);
  use Bric::App::Event qw(log_event);
  use Bric::App::Session qw(:user);
-use Bric::App::Util qw(:aref :msg :history :pkg :browser);
+use Bric::App::Util qw(:aref :msg :history :pkg :browser
:elem);
  use Bric::Biz::ElementType::Parts::FieldType;
  use Bric::Biz::OutputChannel;
  use Bric::Biz::OutputChannel::Element;
 -538,9
+538,8 
              if ($param-> eq 'codeselect') {
                  # XXX: change if comp/widgets/profile/ 
displayAttrs.mc changes..
                  my $code = $param->;
-                my $items = eval "$code";
-                unless (ref $items eq 'ARRAY' and !($items %
2)) {
-                    add_msg("Invalid codeselect code
(didn't return  
an array ref of even size)");
+                my $items = eval_codeselect($code);
+                unless (ref $items eq 'HASH' or ref $items
eq  
'ARRAY') {
                      $$no_save = 1;
                      return;
                  }



---
Greg Heo
web/software systems developer
gregnode79.com
416.826.7630




Re: Code select verification patch
user name
2008-03-20 11:55:36
Thanks, Scott. I think I tried attaching a file once and it
didn't  
work, so I've always just pasted in the patch text right in
the e-mail.

One more line needs to be deleted (line 543 in the current
rev) to  
match the full patch.


On 20-Mar-08, at 12:31 PM, Lanning, Scott wrote:
> -                my $items = eval "$code";
> -                unless (ref $items eq 'ARRAY' and
!($items % 2)) {
> -                    add_msg("Invalid codeselect
code (didn't return
> an array ref of even size)");

---
Greg Heo
web/software systems developer
gregnode79.com
416.826.7630




Re: Code select verification patch
user name
2008-03-24 09:52:34
On Thu, 20 Mar 2008, Greg Heo wrote:
> One more line needs to be deleted (line 543 in the
current rev) to match
> the full patch.

Deleted. (You don't have svn access?)


> On 20-Mar-08, at 12:31 PM, Lanning, Scott wrote:
>> -                my $items = eval
"$code";
>> -                unless (ref $items eq 'ARRAY' and
!($items % 2)) {
>> -                    add_msg("Invalid
codeselect code (didn't return
>> an array ref of even size)");

Re: Code select verification patch
user name
2008-03-25 11:38:15
On Mar 24, 2008, at 07:52, Scott Lanning wrote:

>> One more line needs to be deleted (line 543 in the
current rev) to  
>> match
>> the full patch.
>
> Deleted. (You don't have svn access?)

Greg, send me your perl.org username and I'll get you svn
access.

Don't have a perl.org username? Go here:

   https://www.bitcard.org/


...and click "Register."

Best,

David

[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )