From d6150d6997e5f98629102623ba4688954d98321b Mon Sep 17 00:00:00 2001 From: kink Date: Sun, 4 Jul 2004 13:24:22 +0000 Subject: [PATCH] Fix output sanitatizing for options and xhtml-fixes. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@7744 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/options.php | 48 ++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/functions/options.php b/functions/options.php index de63a8f4..f9268bbc 100644 --- a/functions/options.php +++ b/functions/options.php @@ -97,7 +97,7 @@ class SquirrelOption { } /* Check for a new value. */ - if ( !sqgetGlobalVar("new_$name", $this->new_value, SQ_POST ) ) { + if ( !sqgetGlobalVar("new_$name", $this->new_value, SQ_POST ) ) { $this->new_value = ''; } @@ -208,33 +208,36 @@ class SquirrelOption { $width = 25; } - $result = "name\" value=\"$this->value\" size=\"$width\" $this->script>"; + $result = "name\" value=\"" . + htmlspecialchars($this->value) . + "\" size=\"$width\" $this->script />\n"; return ($result); } function createWidget_StrList() { /* Begin the select tag. */ - $result = "name\" $this->script>\n"; /* Add each possible value to the select list. */ foreach ($this->possible_values as $real_value => $disp_value) { /* Start the next new option string. */ - $new_option = ""; + $new_option .= '>' . htmlspecialchars($disp_value) . "\n"; /* And add the new option string to our select tag. */ $result .= $new_option; } /* Close the select tag and return our happy result. */ - $result .= ''; + $result .= "\n"; return ($result); } @@ -242,7 +245,7 @@ class SquirrelOption { $selected = array(strtolower($this->value)); /* Begin the select tag. */ - $result = "name\" $this->script>\n"; /* Add each possible value to the select list. */ foreach ($this->possible_values as $real_value => $disp_value) { @@ -251,21 +254,21 @@ class SquirrelOption { $new_option = sqimap_mailbox_option_list(0, $selected, 0, $disp_value); } else { /* Start the next new option string. */ - $new_option = ""; + $new_option .= '>' . htmlspecialchars($disp_value) . "\n"; } /* And add the new option string to our select tag. */ $result .= $new_option; } /* Close the select tag and return our happy result. */ - $result .= ''; + $result .= "\n"; return ($result); } @@ -280,7 +283,8 @@ class SquirrelOption { default: $rows = 5; $cols = 50; } $result = ""; + . "cols=\"$cols\" $this->script>" + . htmlspecialchars($this->value) . "\n"; return ($result); } @@ -291,10 +295,10 @@ class SquirrelOption { // add onChange javascript handler to a regular string widget // which will strip out all non-numeric chars if ($javascript_on) - return preg_replace('/>/', ' onChange="origVal=this.value; newVal=\'\'; ' + return preg_replace('/\/>/', ' onChange="origVal=this.value; newVal=\'\'; ' . 'for (i=0;i=\'0\' ' . '&& origVal.charAt(i)<=\'9\') newVal += origVal.charAt(i); } ' - . 'this.value=newVal;">', $this->createWidget_String()); + . 'this.value=newVal;" />', $this->createWidget_String()); else return $this->createWidget_String(); } @@ -306,10 +310,10 @@ class SquirrelOption { // add onChange javascript handler to a regular string widget // which will strip out all non-numeric (period also OK) chars if ($javascript_on) - return preg_replace('/>/', ' onChange="origVal=this.value; newVal=\'\'; ' + return preg_replace('/\/>/', ' onChange="origVal=this.value; newVal=\'\'; ' . 'for (i=0;i=\'0\' ' . '&& origVal.charAt(i)<=\'9\') || origVal.charAt(i)==\'.\') ' - . 'newVal += origVal.charAt(i); } this.value=newVal;">' + . 'newVal += origVal.charAt(i); } this.value=newVal;" />' , $this->createWidget_String()); else return $this->createWidget_String(); @@ -328,13 +332,13 @@ class SquirrelOption { /* Build the yes choice. */ $yes_option = 'script . '> ' + . $yes_chk . ' ' . $this->script . ' /> ' . ''; /* Build the no choice. */ $no_option = 'script . '> ' + . $no_chk . ' ' . $this->script . ' /> ' . ''; /* Build and return the combined "boolean widget". */ @@ -344,7 +348,8 @@ class SquirrelOption { function createWidget_Hidden() { $result = 'script . '>'; + . '" value="' . htmlspecialchars($this->value) + . '" ' . $this->script . ' />'; return ($result); } @@ -387,7 +392,7 @@ function create_optmode_element($optmode) { function create_hidden_element($name, $value) { $result = ''; + . 'value="' . htmlspecialchars($value) . '" />'; return ($result); } @@ -497,4 +502,5 @@ function OptionSubmit( $name ) { ) . "\n"; } +// vim: et ts=4 ?> -- 2.25.1