Permalink
Browse files

MDL-20821 reverting untested ereg cleanup, not acceptable for stable,…

… sorry
  • Loading branch information...
1 parent 59fa78e commit 58693ff7a606b66bc587fa4a7f3a0819ab5b0dde @skodak skodak committed Nov 19, 2009
@@ -252,9 +252,9 @@ function definition_after_data() {
function arguments($argv) {
$_ARG = array();
foreach ($argv as $arg) {
- if (preg_match('/--?([^=]+)=(.*)/',$arg,$reg)) {
+ if (ereg('--?([^=]+)=(.*)',$arg,$reg)) {
$_ARG[$reg[1]] = $reg[2];
- } elseif(preg_match('/-([a-zA-Z0-9]+)/',$arg,$reg)) {
+ } elseif(ereg('-([a-zA-Z0-9]+)',$arg,$reg)) {
$_ARG[$reg[1]] = 'true';
}
}
@@ -465,15 +465,15 @@ function cleanArguments($args, $commentParams){
$word0 = strtolower($word0);
$word1 = strtolower($word1);
- $wordBase0 = preg_replace('/^[&$]+/','',$word0);
- $wordBase1 = preg_replace('/^[&$]+/','',$word1);
- $startBase = strtolower(preg_replace('/^[&$]+/','',$start));
+ $wordBase0 = ereg_replace('^[&$]+','',$word0);
+ $wordBase1 = ereg_replace('^[&$]+','',$word1);
+ $startBase = strtolower(ereg_replace('^[&$]+','',$start));
if ($wordBase0 == $startBase) {
$type = str_replace(array('(',')'),'', $word1);
} elseif($wordBase1 == $startBase) {
$type = str_replace(array('(',')'),'', $word0);
- } elseif( preg_match('/(^[&$]+)|(\()([a-z0-9]+)(\)$)/', $word0, $regs) ) {
+ } elseif( ereg('(^[&$]+)|(\()([a-z0-9]+)(\)$)', $word0, $regs) ) {
$tail = str_ireplace($word0, '', $end);
$type = $regs[3];
} else {
@@ -535,7 +535,7 @@ function cleanComment($comment){
$comment = str_replace("*/", "", $comment);
$comment = str_replace("*", "", $comment);
$comment = str_replace("\n", "\\n", trim($comment));
- $comment = preg_replace("/[\r\t\n ]+/i", " ", trim($comment));
+ $comment = eregi_replace("[\r\t\n ]+", " ", trim($comment));
$comment = str_replace("\"", "\\\"", $comment);
return $comment;
}
@@ -260,7 +260,7 @@
// normalize username
$user->username = $textlib->strtolower($user->username);
if (empty($CFG->extendedusernamechars)) {
- $user->username = preg_replace('/[^(-\.[:alnum:])]/i', '', $user->username);
+ $user->username = eregi_replace('[^(-\.[:alnum:])]', '', $user->username);
}
if (empty($user->username)) {
$upt->track('status', get_string('missingfield', 'error', 'username'), 'error');
@@ -63,7 +63,7 @@ function user_login($username, $password) {
} else {
// Try to find out using the user's cookie
foreach ($_COOKIE as $name => $value){
- if (preg_match('/_shibsession_/i', $name)){
+ if (eregi('_shibsession_', $name)){
$sessionkey = $value;
}
}
@@ -139,7 +139,7 @@ function LogoutNotification($SessionID){
while (($file = readdir($dh)) !== false) {
// Check if it is a file
if (is_file($dir.'/'.$file)){
- $session_key = preg_replace('/sess_/', '', $file);
+ $session_key = ereg_replace('sess_', '', $file);
// Read session file data
$data = file($dir.'/'.$file);
@@ -246,7 +246,7 @@ function other_method_available($currentmethod)
function validate_aba($aba)
{
- if (preg_match("/^[0-9]{9}$/", $aba)) {
+ if (ereg("^[0-9]{9}$", $aba)) {
$n = 0;
for($i = 0; $i < 9; $i += 3) {
$n += (substr($aba, $i, 1) * 3) + (substr($aba, $i + 1, 1) * 7) + (substr($aba, $i + 2, 1));
@@ -276,45 +276,45 @@ function validate_cc($Num, $Name = "n/a", $Exp = "")
$GoodCard = true;
// Get rid of any non-digits
- $Num = preg_replace("/[^0-9]/", "", $Num);
+ $Num = ereg_replace("[^0-9]", "", $Num);
// Perform card-specific checks, if applicable
switch ($Name)
{
case "mcd" :
- $GoodCard = preg_match("/^5[1-5].{14}$/", $Num);
+ $GoodCard = ereg("^5[1-5].{14}$", $Num);
break;
case "vis" :
- $GoodCard = preg_match("/^4.{15}$|^4.{12}$/", $Num);
+ $GoodCard = ereg("^4.{15}$|^4.{12}$", $Num);
break;
case "amx" :
- $GoodCard = preg_match("/^3[47].{13}$/", $Num);
+ $GoodCard = ereg("^3[47].{13}$", $Num);
break;
case "dsc" :
- $GoodCard = preg_match("/^6011.{12}$/", $Num);
+ $GoodCard = ereg("^6011.{12}$", $Num);
break;
case "dnc" :
- $GoodCard = preg_match("/^30[0-5].{11}$|^3[68].{12}$/", $Num);
+ $GoodCard = ereg("^30[0-5].{11}$|^3[68].{12}$", $Num);
break;
case "jcb" :
- $GoodCard = preg_match("/^3.{15}$|^2131|1800.{11}$/", $Num);
+ $GoodCard = ereg("^3.{15}$|^2131|1800.{11}$", $Num);
break;
case "dlt" :
- $GoodCard = preg_match("/^4.{15}$/", $Num);
+ $GoodCard = ereg("^4.{15}$", $Num);
break;
case "swi" :
- $GoodCard = preg_match("/^[456].{15}$|^[456].{17,18}$/", $Num);
+ $GoodCard = ereg("^[456].{15}$|^[456].{17,18}$", $Num);
break;
case "enr" :
- $GoodCard = preg_match("/^2014.{11}$|^2149.{11}$/", $Num);
+ $GoodCard = ereg("^2014.{11}$|^2149.{11}$", $Num);
break;
}
@@ -146,7 +146,7 @@ function tex_filter ($courseid, $text) {
$texexp = str_replace('</nolink>','',$texexp);
$texexp = str_replace('<span class="nolink">','',$texexp);
$texexp = str_replace('</span>','',$texexp);
- $texexp = preg_replace("#<br[[:space:]]*\/?>#i", '', $texexp); //dlnsk
+ $texexp = eregi_replace("<br[[:space:]]*\/?>", '', $texexp); //dlnsk
$align = "middle";
if (preg_match('/^align=bottom /',$texexp)) {
$align = "text-bottom";
@@ -139,13 +139,13 @@ function rfc2445_is_valid_value($value, $type) {
}
if($scheme === 'mailto') {
- $regexp = '#^[a-zA-Z0-9]+[_a-zA-Z0-9\-]*(\.[_a-z0-9\-]+)*@(([0-9a-zA-Z\-]+\.)+[a-zA-Z][0-9a-zA-Z\-]+|([0-9]{1,3}\.){3}[0-9]{1,3})$#';
+ $regexp = '^[a-zA-Z0-9]+[_a-zA-Z0-9\-]*(\.[_a-z0-9\-]+)*@(([0-9a-zA-Z\-]+\.)+[a-zA-Z][0-9a-zA-Z\-]+|([0-9]{1,3}\.){3}[0-9]{1,3})$';
}
else {
- $regexp = '#^//(.+(:.*)?@)?(([0-9a-zA-Z\-]+\.)+[a-zA-Z][0-9a-zA-Z\-]+|([0-9]{1,3}\.){3}[0-9]{1,3})(:[0-9]{1,5})?(/.*)?$#';
+ $regexp = '^//(.+(:.*)?@)?(([0-9a-zA-Z\-]+\.)+[a-zA-Z][0-9a-zA-Z\-]+|([0-9]{1,3}\.){3}[0-9]{1,3})(:[0-9]{1,5})?(/.*)?$';
}
- return preg_match($regexp, $remain);
+ return ereg($regexp, $remain);
break;
case RFC2445_TYPE_BINARY:
@@ -1,27 +0,0 @@
-18 Nov 2009
-Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below.
-
-Index: iCalendar_rfc2445.php
-===================================================================
-RCS file: /cvsroot/moodle/moodle/lib/bennu/iCalendar_rfc2445.php,v
-retrieving revision 1.2.10.1
-diff -u -r1.2.10.1 iCalendar_rfc2445.php
---- iCalendar_rfc2445.php 12 Oct 2009 05:08:02 -0000 1.2.10.1
-+++ iCalendar_rfc2445.php 18 Nov 2009 06:19:31 -0000
-@@ -139,13 +139,13 @@
- }
-
- if($scheme === 'mailto') {
-- $regexp = '^[a-zA-Z0-9]+[_a-zA-Z0-9\-]*(\.[_a-z0-9\-]+)*@(([0-9a-zA-Z\-]+\.)+[a-zA-Z][0-9a-zA-Z\-]+|([0-9]{1,3}\.){3}[0-9]{1,3})$';
-+ $regexp = '#^[a-zA-Z0-9]+[_a-zA-Z0-9\-]*(\.[_a-z0-9\-]+)*@(([0-9a-zA-Z\-]+\.)+[a-zA-Z][0-9a-zA-Z\-]+|([0-9]{1,3}\.){3}[0-9]{1,3})$#';
- }
- else {
-- $regexp = '^//(.+(:.*)?@)?(([0-9a-zA-Z\-]+\.)+[a-zA-Z][0-9a-zA-Z\-]+|([0-9]{1,3}\.){3}[0-9]{1,3})(:[0-9]{1,5})?(/.*)?$';
-+ $regexp = '#^//(.+(:.*)?@)?(([0-9a-zA-Z\-]+\.)+[a-zA-Z][0-9a-zA-Z\-]+|([0-9]{1,3}\.){3}[0-9]{1,3})(:[0-9]{1,5})?(/.*)?$#';
- }
-
-- return ereg($regexp, $remain);
-+ return preg_match($regexp, $remain);
- break;
-
- case RFC2445_TYPE_BINARY:
@@ -1001,7 +1001,7 @@ function detect_munged_arguments($string, $allowdots=1) {
if (substr_count($string, '..') > $allowdots) { // Sometimes we allow dots in references
return true;
}
- if (preg_match('/[\|\`]/i', $string)) { // check for other bad characters
+ if (ereg('[\|\`]', $string)) { // check for other bad characters
return true;
}
if (empty($string) or $string == '/') {
View
@@ -466,7 +466,7 @@ function _convert($token)
{
return(pack("C", $this->ptg[$token]));
}
- elseif(preg_match("/[A-Z0-9�-�\.]+/",$token))
+ elseif(preg_match("/[A-Z0-9À-Ü\.]+/",$token))
{
return($this->_convert_function($token,$this->_func_args));
}
@@ -723,21 +723,21 @@ function _match($token)
break;
default:
// if it's a reference
- if(preg_match("/^[A-I]?[A-Z][0-9]+$/i",$token) and
- !preg_match("/[0-9]/",$this->_lookahead) and
+ if(eregi("^[A-I]?[A-Z][0-9]+$",$token) and
+ !ereg("[0-9]",$this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.'))
{
return($token);
}
// if it's a range (A1:A2)
- elseif(preg_match("/^[A-I]?[A-Z][0-9]+:[A-I]?[A-Z][0-9]+$/i",$token) and
- !preg_match("/[0-9]/",$this->_lookahead))
+ elseif(eregi("^[A-I]?[A-Z][0-9]+:[A-I]?[A-Z][0-9]+$",$token) and
+ !ereg("[0-9]",$this->_lookahead))
{
return($token);
}
// if it's a range (A1..A2)
- elseif(preg_match("/^[A-I]?[A-Z][0-9]+\.\.[A-I]?[A-Z][0-9]+$/i",$token) and
- !preg_match("/[0-9]/",$this->_lookahead))
+ elseif(eregi("^[A-I]?[A-Z][0-9]+\.\.[A-I]?[A-Z][0-9]+$",$token) and
+ !ereg("[0-9]",$this->_lookahead))
{
return($token);
}
@@ -746,7 +746,7 @@ function _match($token)
return($token);
}
// if it's a function call
- elseif(preg_match("/^[A-Z0-9�-�\.]+$/i",$token) and ($this->_lookahead == "("))
+ elseif(eregi("^[A-Z0-9À-Ü\.]+$",$token) and ($this->_lookahead == "("))
{
return($token);
@@ -857,15 +857,15 @@ function _fact()
return($result);
}
// if it's a reference
- if (preg_match("/^[A-I]?[A-Z][0-9]+$/i",$this->_current_token))
+ if (eregi("^[A-I]?[A-Z][0-9]+$",$this->_current_token))
{
$result = $this->_create_tree($this->_current_token, '', '');
$this->_advance();
return($result);
}
// if it's a range
- elseif (preg_match("/^[A-I]?[A-Z][0-9]+:[A-I]?[A-Z][0-9]+$/i",$this->_current_token) or
- preg_match("/^[A-I]?[A-Z][0-9]+\.\.[A-I]?[A-Z][0-9]+$/i",$this->_current_token))
+ elseif (eregi("^[A-I]?[A-Z][0-9]+:[A-I]?[A-Z][0-9]+$",$this->_current_token) or
+ eregi("^[A-I]?[A-Z][0-9]+\.\.[A-I]?[A-Z][0-9]+$",$this->_current_token))
{
$result = $this->_current_token;
$this->_advance();
@@ -878,7 +878,7 @@ function _fact()
return($result);
}
// if it's a function call
- elseif (preg_match("/^[A-Z0-9�-�\.]+$/i",$this->_current_token))
+ elseif (eregi("^[A-Z0-9À-Ü\.]+$",$this->_current_token))
{
$result = $this->_func();
return($result);
@@ -1,13 +1,13 @@
18 Nov 2009
-Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below.
+Description of WriteExcel modifications to remove functions deprecated as of php 5.3
Index: Parser.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/excel/Parser.php,v
retrieving revision 1.1
diff -u -r1.1 Parser.php
--- Parser.php 26 Sep 2003 04:18:02 -0000 1.1
-+++ Parser.php 18 Nov 2009 06:27:54 -0000
++++ Parser.php 18 Nov 2009 03:58:49 -0000
@@ -466,7 +466,7 @@
{
return(pack("C", $this->ptg[$token]));
@@ -88,7 +88,7 @@ RCS file: /cvsroot/moodle/moodle/lib/excel/Worksheet.php,v
retrieving revision 1.1
diff -u -r1.1 Worksheet.php
--- Worksheet.php 26 Sep 2003 04:18:02 -0000 1.1
-+++ Worksheet.php 18 Nov 2009 06:27:55 -0000
++++ Worksheet.php 18 Nov 2009 03:58:50 -0000
@@ -1264,10 +1264,10 @@
}
View
@@ -496,7 +496,7 @@ function mimeinfo($element, $filename) {
$mimeinfo = get_mimetypes_array();
}
- if (preg_match('/\.([a-z0-9]+)$/i', $filename, $match)) {
+ if (eregi('\.([a-z0-9]+)$', $filename, $match)) {
if (isset($mimeinfo[strtolower($match[1])][$element])) {
return $mimeinfo[strtolower($match[1])][$element];
} else {
@@ -171,7 +171,7 @@ function MakeFontDescriptor($fm,$symbolic)
//StemV
if(isset($fm['StdVW']))
$stemv=$fm['StdVW'];
- elseif(isset($fm['Weight']) and preg_match('/(bold|black)/i',$fm['Weight']))
+ elseif(isset($fm['Weight']) and eregi('(bold|black)',$fm['Weight']))
$stemv=120;
else
$stemv=70;
@@ -1,19 +0,0 @@
-18 Nov 2009
-Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below.
-
-Index: font/makefont/makefont.php
-===================================================================
-RCS file: /cvsroot/moodle/moodle/lib/fpdf/font/makefont/Attic/makefont.php,v
-retrieving revision 1.2
-diff -u -r1.2 makefont.php
---- font/makefont/makefont.php 16 May 2006 06:45:14 -0000 1.2
-+++ font/makefont/makefont.php 18 Nov 2009 06:32:46 -0000
-@@ -171,7 +171,7 @@
- //StemV
- if(isset($fm['StdVW']))
- $stemv=$fm['StdVW'];
-- elseif(isset($fm['Weight']) and eregi('(bold|black)',$fm['Weight']))
-+ elseif(isset($fm['Weight']) and preg_match('/(bold|black)/i',$fm['Weight']))
- $stemv=120;
- else
- $stemv=70;
View
@@ -490,7 +490,7 @@ function getdnsattributes ($l,$ip){
$r->nameservers = array("ws1.maxmind.com");
$p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
$str = is_object($p->answer[0])?$p->answer[0]->string():'';
- preg_match("/\"(.*)\"/",$str,$regs);
+ ereg("\"(.*)\"",$str,$regs);
$str = $regs[1];
return $str;
}
@@ -1,19 +0,0 @@
-18 Nov 2009
-Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below.
-
-Index: geoip.inc
-===================================================================
-RCS file: /cvsroot/moodle/moodle/lib/geoip/geoip.inc,v
-retrieving revision 1.1.2.2
-diff -u -r1.1.2.2 geoip.inc
---- geoip.inc 2 Jan 2008 16:49:05 -0000 1.1.2.2
-+++ geoip.inc 18 Nov 2009 06:34:59 -0000
-@@ -490,7 +490,7 @@
- $r->nameservers = array("ws1.maxmind.com");
- $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
- $str = is_object($p->answer[0])?$p->answer[0]->string():'';
-- ereg("\"(.*)\"",$str,$regs);
-+ preg_match("/\"(.*)\"/",$str,$regs);
- $str = $regs[1];
- return $str;
- }
@@ -12,7 +12,7 @@ class HTMLPurifier_AttrDef_Lang extends HTMLPurifier_AttrDef
function validate($string, $config, &$context) {
// moodle change - we use special lang strings unfortunatelly
- return preg_replace('/[^0-9a-zA-Z_-]/', '', $string);
+ return ereg_replace('[^0-9a-zA-Z_-]', '', $string);
// moodle change end
$string = trim($string);
@@ -8,24 +8,3 @@ Changes:
skodak
$Id$
-
-
-18 Nov 2009
-Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below.
-
-Index: HTMLPurifier/AttrDef/Lang.php
-===================================================================
-RCS file: /cvsroot/moodle/moodle/lib/htmlpurifier/HTMLPurifier/AttrDef/Lang.php,v
-retrieving revision 1.3
-diff -u -r1.3 Lang.php
---- HTMLPurifier/AttrDef/Lang.php 25 Sep 2007 14:34:13 -0000 1.3
-+++ HTMLPurifier/AttrDef/Lang.php 18 Nov 2009 06:37:14 -0000
-@@ -12,7 +12,7 @@
- function validate($string, $config, &$context) {
-
- // moodle change - we use special lang strings unfortunatelly
-- return ereg_replace('[^0-9a-zA-Z_-]', '', $string);
-+ return preg_replace('/[^0-9a-zA-Z_-]/', '', $string);
- // moodle change end
-
- $string = trim($string);
Oops, something went wrong. Retry.

0 comments on commit 58693ff

Please sign in to comment.