Skip to content

Commit af41912

Browse files
author
JasWSInc
committed
Bug fix; $_GET, $_POST, $_REQUEST, $_COOKIE, $_SESSION replacement codes. Improving and correcting regex pattern and callback namespace. See: #18
1 parent e6d4956 commit af41912

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

wp-redirects/wp-redirects.inc.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public static function redirect_redirects()
217217
$redirect_id = get_the_ID(); // Pull this one time only.
218218

219219
$to = (string)get_post_meta($redirect_id, 'wp_redirect_to', TRUE);
220-
$to = preg_replace_callback('/%%\\\$([^\[]+?)(.+?)%%/i', 'wp_redirects\plugin::_url_e_gprcs_value', $to);
220+
$to = preg_replace_callback('/%%\$([^[]+?)(\[.+?)%%/i', '\\wp_redirects\\plugin::_url_e_gprcs_value', $to);
221221
$to = preg_replace('/%%(.+?)%%/i', '', $to); // Ditch any remaining replacement codes.
222222

223223
$to = // Cleanup any double slashes left over by replacement codes.
@@ -274,7 +274,7 @@ public function redirect_uri_patterns()
274274
{
275275
return urlencode((string)@$_is_regex_matches[$m[1]]);
276276
}, $_to) : $_to);
277-
$_to = preg_replace_callback('/%%\\\$([^\[]+?)(.+?)%%/i', 'wp_redirects\plugin::_url_e_gprcs_value', $_to);
277+
$_to = preg_replace_callback('/%%\$([^[]+?)(\[.+?)%%/i', '\\wp_redirects\\plugin::_url_e_gprcs_value', $_to);
278278
$_to = preg_replace('/%%(.+?)%%/i', '', $_to); // Ditch any remaining replacement codes.
279279

280280
$_to = // Cleanup any double slashes left over by replacement codes.
@@ -303,7 +303,7 @@ public static function _url_e_gprcs_value($m)
303303
if(strlen($element_w_brackets = $m[2]) && preg_match('/^(?:(?:\[(["\'])[a-z0-9 \._\-]+?\\1\])|(?:\[[0-9]+\]))+$/i', $element_w_brackets))
304304
eval('$value = urlencode(trim(stripslashes((string)@$'.$gprcs.$element_w_brackets.')));');
305305

306-
return (!empty($value)) ? $value : ''; // Default to empty string.
306+
return !empty($value) ? $value : ''; // Default to empty string.
307307
}
308308

309309
public static function get_redirect_hits($post_id) {

0 commit comments

Comments
 (0)