File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,11 +50,11 @@ public function getError($languageKey = NULL) {
5050 return isset ($ this ->errors [$ languageKey ]) ? I18N ::_ ($ this ->errors [$ languageKey ]) : NULL ;
5151 }
5252
53- public static function getPostValues ($ name , $ languages ) {
53+ public static function getPostValues ($ name , $ languages, $ filter = NULL ) {
5454 $ rc = array ();
5555 $ request = \TgUtils \Request::getRequest ();
5656 foreach ($ languages AS $ key => $ label ) {
57- $ rc [$ key ] = $ request ->getPostParam ($ name .'- ' .$ key );
57+ $ rc [$ key ] = $ request ->getPostParam ($ name .'- ' .$ key, NULL , $ filter );
5858 if ($ rc [$ key ] != NULL ) $ rc [$ key ] = trim ($ rc [$ key ]);
5959 }
6060 return $ rc ;
Original file line number Diff line number Diff line change 55use TgLog \Log ;
66use TgLog \Error ;
77use WebApp \Component \Alert ;
8+ use TgUtils \StringFilters ;
89
910class RestPage extends Page {
1011
@@ -110,10 +111,18 @@ protected function getJsonBody() {
110111 return $ this ->jsonBody ;
111112 }
112113
113- protected function getJsonParam ($ key , $ default = NULL ) {
114+ /**
115+ * Returns the JSON parameter with the given key.
116+ * @param string $key - the object attribute of root JSON object
117+ * @param mixed $default - the default value if not available
118+ * @param StringFilter $filter - the filter to apply for the param (NULL will mean NOHTML)
119+ * @return the filtered value or default value.
120+ */
121+ protected function getJsonParam ($ key , $ default = NULL , $ filter = NULL ) {
114122 $ obj = $ this ->getJsonBody ();
115123 if (!isset ($ obj ->$ key )) return $ default ;
116- return $ obj ->$ key ;
124+ if ($ filter == NULL ) $ filter = StringFilters::$ NO_HTML ;
125+ return $ filter ->filter ($ obj ->$ key );
117126 }
118127}
119128
You can’t perform that action at this time.
0 commit comments