From 40b6df30c5a1e8f3597a2ded8bca592530023cca Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Mon, 23 Jul 2012 05:01:44 -0400
Subject: [PATCH] Fixed scrollbars in Larry's iframes

---
 plugins/managesieve/managesieve.php |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/plugins/managesieve/managesieve.php b/plugins/managesieve/managesieve.php
index 7f591f5..70b280d 100644
--- a/plugins/managesieve/managesieve.php
+++ b/plugins/managesieve/managesieve.php
@@ -854,17 +854,22 @@
                     break;
 
                 case 'set':
+                    $this->form['actions'][$i]['name'] = $varnames[$idx];
+                    $this->form['actions'][$i]['value'] = $varvalues[$idx];
+                    foreach ((array)$varmods[$idx] as $v_m) {
+                        $this->form['actions'][$i][$v_m] = true;
+                    }
+
                     if (empty($varnames[$idx])) {
                         $this->errors['actions'][$i]['name'] = $this->gettext('cannotbeempty');
                     }
-                    if (empty($varvalues[$idx])) {
+                    else if (!preg_match('/^[0-9a-z_]+$/i', $varnames[$idx])) {
+                        $this->errors['actions'][$i]['name'] = $this->gettext('forbiddenchars');
+                    }
+
+                    if (!isset($varvalues[$idx]) || $varvalues[$idx] === '') {
                         $this->errors['actions'][$i]['value'] = $this->gettext('cannotbeempty');
                     }
-                    foreach ($varmods[$idx] as $v_m) {
-                        $this->form['actions'][$i][$v_m] = true;
-                    }
-                    $this->form['actions'][$i]['name'] = $varnames[$idx];
-                    $this->form['actions'][$i]['value'] = $varvalues[$idx];
                     break;
                 }
 
@@ -1553,7 +1558,9 @@
         foreach ($set_modifiers as $j => $s_m) {
             $s_m_id = 'action_varmods' . $id . $s_m;
             $out .= sprintf('<input type="checkbox" name="_action_varmods[%s][]" value="%s" id="%s"%s />%s<br>',
-                $id, $s_m, $s_m_id, (array_key_exists($s_m, (array)$action) && $action[$s_m] ? ' checked="checked"' : ''), $s_m);
+                $id, $s_m, $s_m_id,
+                (array_key_exists($s_m, (array)$action) && $action[$s_m] ? ' checked="checked"' : ''),
+                Q($this->gettext('var' . $s_m)));
         }
         $out .= '</div>';
 

--
Gitblit v1.9.1