]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #1512: Using a helper function for mb_parse_str() instead of wrapping it exactly.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 12 Feb 2010 14:56:20 +0000 (14:56 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 12 Feb 2010 14:56:20 +0000 (14:56 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@3934 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/api.php
engine/lib/elgglib.php
engine/lib/input.php
engine/lib/mb_wrapper.php
engine/lib/pagehandler.php
mod/search/views/default/search/listing.php

index ffb1e16afab2f9f2adfe99ce3dfbc1bbc6601c8a..d123ff360aaa608fa35709bb6643fe79c3da644f 100644 (file)
@@ -560,7 +560,7 @@ function include_post_data() {
        $postdata = get_post_data();
 
        if (isset($postdata)) {
-               elgg_parse_str($postdata, $query_arr);
+               $query_arr = elgg_parse_str($postdata);
                if (is_array($query_arr)) {
                        foreach($query_arr as $name => $val) {
                                set_input($name, $val);
@@ -1342,7 +1342,7 @@ function list_all_apis() {
 /**
  * The auth.gettoken API.
  * This API call lets a user log in, returning an authentication token which can be used
- * to authenticate a user for a period of time. It is passed in future calls as the parameter 
+ * to authenticate a user for a period of time. It is passed in future calls as the parameter
  * auth_token.
  *
  * @param string $username Username
@@ -1439,7 +1439,7 @@ function service_handler($handler, $request) {
        // setup the input parameters since this comes through rewrite rule
        $query = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?')+1);
        if (isset($query)) {
-               elgg_parse_str($query, $query_arr);
+               $query_arr = elgg_parse_str($query);
                if (is_array($query_arr)) {
                        foreach($query_arr as $name => $val) {
                                set_input($name, $val);
index 52b4ecf3203cd92928d587682931438a4bee7113..91334821da2360242aa3ed17d6139cbddc18119c 100644 (file)
@@ -943,11 +943,11 @@ function get_submenu() {
                                                $item_params = array();
                                                if (isset($uri_info['query'])) {
                                                        $uri_info['query'] = html_entity_decode($uri_info['query']);
-                                                       elgg_parse_str($uri_info['query'], $uri_params);
+                                                       $uri_params = elgg_parse_str($uri_info['query']);
                                                }
                                                if (isset($item_info['query'])) {
                                                        $item_info['query'] = html_entity_decode($item_info['query']);
-                                                       elgg_parse_str($item_info['query'], $item_params);
+                                                       $item_params = elgg_parse_str($item_info['query']);
                                                }
 
                                                $uri_info['path'] = trim($uri_info['path'], '/');
@@ -2521,7 +2521,7 @@ function elgg_validate_action_url($link) {
        $url = parse_url($link);
 
        if (isset($url['query'])) {
-               elgg_parse_str($url['query'], $query);
+               $query = elgg_parse_str($url['query']);
        } else {
                $query = array();
        }
@@ -2550,7 +2550,7 @@ function elgg_http_remove_url_query_element($url, $element) {
        $url_array = parse_url($url);
 
        if (isset($url_array['query'])) {
-               elgg_parse_str($url_array['query'], $query);
+               $query = elgg_parse_str($url_array['query']);
        } else {
                // nothing to remove. Return original URL.
                return $url;
@@ -2577,7 +2577,7 @@ function elgg_http_add_url_query_elements($url, array $elements) {
        $url_array = parse_url($url);
 
        if (isset($url_array['query'])) {
-               elgg_parse_str($url_array['query'], $query);
+               $query = elgg_parse_str($url_array['query']);
        } else {
                $query = array();
        }
index a4ab696cc2758fb57ee382bfc06130d68c5be4eb..89bab585356fd3e42adc4bb132644cadd754807e 100644 (file)
@@ -190,7 +190,7 @@ function autop($pee, $br = 1) {
  */
 function elgg_set_input_from_uri() {
        $query = parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY);
-       elgg_parse_str($query, $query_arr);
+       $query_arr = elgg_parse_str($query);
 
        if (is_array($query_arr)) {
                foreach($query_arr as $name => $val) {
index 8bd9ddb8b5012f86d13b272e98b4a3f7a22a49d3..9aa4aac4c7d66358239b8947371c8403eb23299d 100644 (file)
@@ -6,6 +6,24 @@ if (is_callable('mb_internal_encoding')) {
        ini_set("mbstring.internal_encoding", 'UTF-8');
 }
 
+/**
+ * Parses a string using mb_parse_str() if available.
+ * NOTE: This differs from parse_str() by returning the results
+ * instead of placing them in the local scope!
+ *
+ * @param str $str
+ * @return array
+ */
+function elgg_parse_str($str) {
+       if (is_callable('mb_parse_str')) {
+               mb_parse_str($str, $results);
+       } else {
+               parse_str($str, $results);
+       }
+
+       return $results;
+}
+
 // map string functions to their mb_str_func alternatives
 // and wrap them in elgg_str_fun()
 
@@ -13,7 +31,8 @@ if (is_callable('mb_internal_encoding')) {
 // only will work with mb_* functions that take the same
 // params in the same order as their non-mb safe counterparts.
 $str_funcs = array(
-       'parse_str',
+       // can't wrap parse_str() because of its 2nd parameter.
+       //'parse_str',
        'split',
        'stristr',
        'strlen',
index 792ead84ff968952bb909bf1e979671b7724d356..8d0f9abee9ee44ca869147f3240437931358ca2d 100644 (file)
@@ -24,7 +24,7 @@ function page_handler($handler, $page) {
        if (strpos($_SERVER['REQUEST_URI'], '?') !== FALSE) {
                $query = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?') + 1);
                if (isset($query)) {
-                       elgg_parse_str($query, $query_arr);
+                       $query_arr = elgg_parse_str($query);
                        if (is_array($query_arr)) {
                                foreach($query_arr as $name => $val) {
                                        set_input($name, $val);
index 5142e1fe52a3c8037c1059397518794649b6f629..8825b7e8d29089b7e28964ed5fdcabe1c454dbe5 100644 (file)
@@ -15,7 +15,7 @@ if (!is_array($entities) || !count($entities)) {
        return FALSE;
 }
 
-$query = htmlspecialchars(http_build_query(
+$query = http_build_query(
        array(
                'q' => $vars['params']['query'],
                'entity_type' => $vars['params']['type'],
@@ -25,7 +25,7 @@ $query = htmlspecialchars(http_build_query(
                'search_type' => $vars['params']['search_type'],
        //@todo include vars for sorting, order, and friend-only.
        )
-));
+);
 
 $url = "{$vars['url']}pg/search?$query";