11<?php
2- // eForm 1.4.6 - Electronic Form Snippet
2+ // eForm 1.4.8 - Electronic Form Snippet
33// Original created by: Raymond Irving 15-Dec-2004.
44// Extended by: Jelle Jager (TobyL) September 2006
55// -----------------------------------------------------
@@ -54,7 +54,7 @@ function eForm($modx,$params) {
5454
5555 extract ($ params ,EXTR_SKIP ); // extract params into variables
5656
57- $ fileVersion = '1.4.6 ' ;
57+ $ fileVersion = '1.4.8 ' ;
5858 $ version = isset ($ version ) ? $ version : 'prior to 1.4.2 ' ;
5959
6060 // include default language file
@@ -166,18 +166,17 @@ function eForm($modx,$params) {
166166
167167 // get user post back data
168168 foreach ($ _POST as $ name => $ value ){
169- if (is_array ($ value )){
170- //remove empty values
171- $ fields [$ name ] = array_filter ($ value ,create_function ('$v ' ,'return (!empty($v)); ' ));
169+ if (is_array ($ value )){ // type="checkbox" etc. remove empty values
170+ $ value = array_filter ($ value ,create_function ('$v ' ,'return (!empty($v)); ' ));
172171 } else {
173- if ($ allowhtml && $ formats [$ name ][2 ]=='html ' ) {
174- $ fields [$ name ] = stripslashes ($ value );
175- } else {
176- $ fields [$ name ] = strip_tags (stripslashes ($ value ));
177- }
172+ if (get_magic_quotes_gpc ()) $ value = stripslashes ($ value ); // For before PHP 5.3
173+ if (!$ allowhtml || $ formats [$ name ][2 ]!='html ' ) $ value = strip_tags ($ value );
178174 }
175+ $ fields [$ name ] = $ value ;
179176 }
180-
177+
178+ modx_sanitize_gpc ($ fields ); // Remove the danger values that the result of stripslashes and strip_tags.
179+
181180 // get uploaded files
182181 foreach ($ _FILES as $ name => $ value ){
183182 $ fields [$ name ] = $ value ;
@@ -192,24 +191,8 @@ function eForm($modx,$params) {
192191 $ rClass ['vericode ' ]=$ invalidClass ; //added in 1.4.4
193192 }
194193 }
195-
196- // sanitize the values with slashes stripped to avoid remote execution of Snippets
197- $ version = $ modx ->getVersionData ();
198- if (version_compare ($ version ['version ' ], '1.0.9 ' , '<= ' )) {
199- modx_sanitize_gpc ($ fields , array (
200- '@<script[^>]*?>.*?</script>@si ' ,
201- '@&#(\d+);@e ' ,
202- '@\[\~(.*?)\~\]@si ' ,
203- '@\[\((.*?)\)\]@si ' ,
204- '@{{(.*?)}}@si ' ,
205- '@\[\+(.*?)\+\]@si ' ,
206- '@\[\*(.*?)\*\]@si ' ,
207- '@\[\[(.*?)\]\]@si ' ,
208- '@\[!(.*?)!\]@si '
209- ));
210- }
211-
212- # validate fields
194+
195+ // validate fields
213196 foreach ($ fields as $ name => $ value ) {
214197 $ fld = $ formats [$ name ];
215198 if ($ fld ) {
0 commit comments