- Timestamp:
- Aug 8, 2019 10:03:59 PM (5 years ago)
- Location:
- trunk/lib
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/CSS.inc.php
r603 r696 182 182 // Strip whitespace and print file. 183 183 echo preg_replace( 184 array('!/\*.*?\*/!s ', '/[\n\r]+/', '/([;:])\s+/m', '/\s*}[ \t]*/', '/\s*{\s*/', '/[ \t\n\r]*,[ \t\n\r]*/', '/^\s+/'),184 array('!/\*.*?\*/!su', '/[\n\r]+/u', '/([;:])\s+/mu', '/\s*}[ \t]*/u', '/\s*{\s*/u', '/[ \t\n\r]*,[ \t\n\r]*/u', '/^\s+/u'), 185 185 array('', "\n", '$1', '}', '{', ',', ''), file_get_contents($file, true) 186 186 ); -
trunk/lib/Email.inc.php
r684 r696 118 118 . '(?:\s*>\s*|>\s+\([^,@]+\)\s*)' // TRUE, ensure ending > 119 119 . '|' 120 . '(?:|\s*|\s+\([^,@]+\)\s*))$/i ')); // FALSE ensure there is no ending >120 . '(?:|\s*|\s+\([^,@]+\)\s*))$/iu')); // FALSE ensure there is no ending > 121 121 122 122 if (isset($params)) { … … 260 260 // Apply regex pattern to search elements. 261 261 $search = array_keys($replacements); 262 array_walk($search, create_function('&$v', '$v = "{" . mb_strtoupper($v) . "}";')); 262 array_walk($search, function (&$v) { 263 $v = '{' . mb_strtoupper($v) . '}'; 264 }); 263 265 264 266 // Replacement values. … … 274 276 * You can also use this function to do post-processing on the email body before sending it, 275 277 * like removing extraneous lines: 276 * $email->setString(preg_replace('/(?:(?:\r\n|\r|\n)\s*){2}/s ', "\n\n", $email->getBody()));278 * $email->setString(preg_replace('/(?:(?:\r\n|\r|\n)\s*){2}/su', "\n\n", $email->getBody())); 277 279 * 278 280 * @access public … … 367 369 foreach ($headers as $key => $val) { 368 370 // Validate key and values. 369 if ( empty($val)) {371 if (!strlen($val)) { 370 372 $app->logMsg(sprintf('Empty email header provided: %s', $key), LOG_NOTICE, __FILE__, __LINE__); 371 373 continue; 372 374 } 373 if ( empty($key) || !is_string($key) || !is_string($val) || preg_match("/[\n\r]/", $key . $val) || preg_match('/[^\w-]/', $key)) {375 if (!strlen($key) || preg_match("/[\n\r]/", $key . $val) || preg_match('/[^\w-]/', $key)) { 374 376 $app->logMsg(sprintf('Broken email header provided: %s=%s', $key, $val), LOG_WARNING, __FILE__, __LINE__); 375 377 continue; … … 394 396 $envelope_sender_address = sprintf('<%s>', trim($this->_params['envelope_sender_address'], '<>')); 395 397 } else { 396 $envelope_sender_address = preg_replace('/^.*<?([^\s@\[\]<>()]+\@[A-Za-z0-9.-]{1,}\.[A-Za-z]{2,5})>?$/iU ', '$1', $this->_params['from']);398 $envelope_sender_address = preg_replace('/^.*<?([^\s@\[\]<>()]+\@[A-Za-z0-9.-]{1,}\.[A-Za-z]{2,5})>?$/iUu', '$1', $this->_params['from']); 397 399 } 398 400 if ('' != $envelope_sender_address && $this->validEmail($envelope_sender_address)) { -
trunk/lib/JS.inc.php
r603 r696 182 182 // Strip whitespace and print file. 183 183 echo preg_replace( 184 array('/(?<=^|;|{)\s*\/\/.*$/m ', '/(?<=^|;|{)\s*\/\*.*?\*\//ms', '/[\n\r]+/', '/[ \t]+}[ \t]+/', '/[ \t]+{[ \t]+/', '/\s+=\s+/', '/^[ \t]+/m', '/[ \t]+$/m'),184 array('/(?<=^|;|{)\s*\/\/.*$/mu', '/(?<=^|;|{)\s*\/\*.*?\*\//msu', '/[\n\r]+/u', '/[ \t]+}[ \t]+/u', '/[ \t]+{[ \t]+/u', '/\s+=\s+/u', '/^[ \t]+/mu', '/[ \t]+$/mu'), 185 185 array('', '', "\n", '}', '{', '=', '', ''), file_get_contents($file, true) 186 186 ); -
trunk/lib/Utilities.inc.php
r690 r696 122 122 $d = ob_get_contents(); 123 123 ob_end_clean(); 124 return $serialize ? preg_replace('/\s+/m ', ' ', $d) : $d;124 return $serialize ? preg_replace('/\s+/mu', ' ', $d) : $d; 125 125 } 126 126 … … 154 154 $output .= sprintf("%s%s\n", $indent_str, $var); 155 155 } 156 return preg_replace(['/^[ \t]+$/ ', '/\n\n+/', '/^(?:\S( ))?(?:\S( ))?(?:\S( ))?(?:\S( ))?(?:\S( ))?(?:\S( ))?(?:\S( ))?(?:\S( ))?(\S )/m'], ['', "\n", '$1$1$2$2$3$3$4$4$5$5$6$6$7$7$8$8$9'], $output);156 return preg_replace(['/^[ \t]+$/u', '/\n\n+/u', '/^(?:\S( ))?(?:\S( ))?(?:\S( ))?(?:\S( ))?(?:\S( ))?(?:\S( ))?(?:\S( ))?(?:\S( ))?(\S )/mu'], ['', "\n", '$1$1$2$2$3$3$4$4$5$5$6$6$7$7$8$8$9'], $output); 157 157 } 158 158 … … 189 189 190 190 // Make converted ampersand entities into normal ampersands (they will be done manually later) to retain HTML entities. 191 $search['retain_ampersand'] = '/&/ ';191 $search['retain_ampersand'] = '/&/u'; 192 192 $replace['retain_ampersand'] = '&'; 193 193 194 194 if ($preserve_html) { 195 195 // Convert characters that must remain non-entities for displaying HTML. 196 $search['retain_left_angle'] = '/</ ';196 $search['retain_left_angle'] = '/</u'; 197 197 $replace['retain_left_angle'] = '<'; 198 198 199 $search['retain_right_angle'] = '/>/ ';199 $search['retain_right_angle'] = '/>/u'; 200 200 $replace['retain_right_angle'] = '>'; 201 201 202 $search['retain_single_quote'] = '/'/ ';202 $search['retain_single_quote'] = '/'/u'; 203 203 $replace['retain_single_quote'] = "'"; 204 204 205 $search['retain_double_quote'] = '/"/ ';205 $search['retain_double_quote'] = '/"/u'; 206 206 $replace['retain_double_quote'] = '"'; 207 207 } … … 309 309 // If not truncating, or URL was not truncated. 310 310 // Remove http schemas, and any single trailing / to make the display URL. 311 $display_url = preg_replace(['!^https?://! ', '!^([^/]+)/$!'], ['', '$1'], $url);311 $display_url = preg_replace(['!^https?://!u', '!^([^/]+)/$!u'], ['', '$1'], $url); 312 312 return sprintf('<a href="%s">%s</a>', oTxt($absolute_url), $display_url); 313 313 } else { 314 314 // Truncated URL. 315 315 // Remove http schemas, and any single trailing / to make the display URL. 316 $display_url = preg_replace(['!^https?://! ', '!^([^/]+)/$!'], ['', '$1'], trim($truncated_url));316 $display_url = preg_replace(['!^https?://!u', '!^([^/]+)/$!u'], ['', '$1'], trim($truncated_url)); 317 317 return sprintf('<a href="%s">%s%s</a>', oTxt($absolute_url), $display_url, $delim); 318 318 } … … 337 337 foreach ($words as $w) { 338 338 if ('' != trim($w)) { 339 $search[] = '/\b(' . preg_quote($w) . ')\b/i ';339 $search[] = '/\b(' . preg_quote($w) . ')\b/iu'; 340 340 $replace[] = '<span class="' . $class . '">$1</span>'; 341 341 } … … 368 368 default : 369 369 // Reduce all hex values slightly to avoid all white. 370 array_walk($rgb, create_function('&$v', "\$v = dechex(round(hexdec(\$v) * $n));")); 370 array_walk($rgb, function (&$v) use ($n) { 371 $v = dechex(round(hexdec($v) * $n)); 372 }); 371 373 break; 374 372 375 case 2 : 373 376 foreach ($rgb as $i => $v) { … … 411 414 function encodeEmail($email, $at=' at ', $dot=' dot ') 412 415 { 413 $search = array('/@/ ', '/\./');416 $search = array('/@/u', '/\./u'); 414 417 $replace = array($at, $dot); 415 418 return preg_replace($search, $replace, $email); … … 529 532 function URLSlug($str) 530 533 { 531 $slug = preg_replace(array('/\W+/u', '/^-+|-+$/ '), array('-', ''), $str);534 $slug = preg_replace(array('/\W+/u', '/^-+|-+$/u'), array('-', ''), $str); 532 535 $slug = strtolower($slug); 533 536 return $slug; … … 1138 1141 function hash64($string, $length=18) 1139 1142 { 1140 return mb_substr(preg_replace('/[^\w]/ ', '', base64_encode(hash('sha512', $string, true))), 0, $length);1143 return mb_substr(preg_replace('/[^\w]/u', '', base64_encode(hash('sha512', $string, true))), 0, $length); 1141 1144 } 1142 1145 … … 1168 1171 switch ($app->getParam('signing_method')) { 1169 1172 case 'sha512+base64': 1170 return $val . '-' . mb_substr(preg_replace('/[^\w]/ ', '', base64_encode(hash('sha512', $val . $salt, true))), 0, $length);1173 return $val . '-' . mb_substr(preg_replace('/[^\w]/u', '', base64_encode(hash('sha512', $val . $salt, true))), 0, $length); 1171 1174 1172 1175 case 'md5': … … 1395 1398 function stripQuery($url) 1396 1399 { 1397 return preg_replace('/[?#].*$/ ', '', $url);1400 return preg_replace('/[?#].*$/u', '', $url); 1398 1401 } 1399 1402 … … 1405 1408 function absoluteMe() 1406 1409 { 1407 $safe_http_host = preg_replace('/[^a-z\d.:-]/ ', '', getenv('HTTP_HOST'));1410 $safe_http_host = preg_replace('/[^a-z\d.:-]/u', '', getenv('HTTP_HOST')); 1408 1411 return sprintf('%s://%s%s', (getenv('HTTPS') ? 'https' : 'http'), $safe_http_host, getenv('REQUEST_URI')); 1409 1412 } … … 1422 1425 // If one of the hostnames is an IP address, compare only the path of both. 1423 1426 if (preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', parse_url($current_url, PHP_URL_HOST)) || preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', parse_url($referrer_url, PHP_URL_HOST))) { 1424 $current_url = preg_replace('@^https?://[^/]+@ ', '', $current_url);1425 $referrer_url = preg_replace('@^https?://[^/]+@ ', '', $referrer_url);1427 $current_url = preg_replace('@^https?://[^/]+@u', '', $current_url); 1428 $referrer_url = preg_replace('@^https?://[^/]+@u', '', $referrer_url); 1426 1429 } 1427 1430 -
trunk/lib/Validator.inc.php
r635 r696 453 453 $app =& App::getInstance(); 454 454 // Get rid of any non-digits 455 $cc_num = preg_replace('/[^\d]/ ', '', $val);455 $cc_num = preg_replace('/[^\d]/u', '', $val); 456 456 457 457 // Perform card-specific checks, if applicable
Note: See TracChangeset
for help on using the changeset viewer.