[Fusionforge-commits] r14921 - trunk/src/common/include

Alain Peyrat aljeux at fusionforge.org
Wed Nov 23 20:40:29 CET 2011


Author: aljeux
Date: 2011-11-23 20:40:28 +0100 (Wed, 23 Nov 2011)
New Revision: 14921

Modified:
   trunk/src/common/include/escapingUtils.php
Log:
Add getHtmlStringFromRequest() and getHtmlTextFromRequest() functions

Modified: trunk/src/common/include/escapingUtils.php
===================================================================
--- trunk/src/common/include/escapingUtils.php	2011-11-23 19:40:22 UTC (rev 14920)
+++ trunk/src/common/include/escapingUtils.php	2011-11-23 19:40:28 UTC (rev 14921)
@@ -43,6 +43,34 @@
 }
 
 /**
+ * getHtmlStringFromRequest - get an htmlified string from REQUEST
+ *
+ * @param string $key key of the wanted value
+ * @param string $defaultValue if we can't find the wanted value, it returns the default value
+ * @return string the value
+ */
+function getHtmlStringFromRequest($key, $defaultValue = '') {
+	return htmlspecialchars(getStringFromRequest($key, $defaultValue));
+}
+
+/**
+ * getHtmlTextFromRequest - get an htmlified text string from REQUEST (same as string but for textarea)
+ *
+ * @param string $key key of the wanted value
+ * @param string $defaultValue if we can't find the wanted value, it returns the default value
+ * @return string the value
+ */
+function getHtmlTextFromRequest($key, $defaultValue = '') {
+	$text = _getStringFromArray(_getRequestArray(), $key, $defaultValue);
+
+	if (getStringFromRequest('_'.$key.'_content_type') == 'html') {
+		return TextSanitizer::purify($text);
+	} else {
+		return htmlspecialchars($text);
+	}
+}
+
+/**
  * getArrayFromRequest - get an array from REQUEST
  * @param	string $key	Key of the wanted value
  * @param	string $defaultValue	if we can't find the wanted value, it returns the default value




More information about the Fusionforge-commits mailing list