? MDL2082119patch.txt ? config.php Index: admin/uploaduser.php =================================================================== RCS file: /cvsroot/moodle/moodle/admin/uploaduser.php,v retrieving revision 1.68.2.15 diff -u -r1.68.2.15 uploaduser.php --- admin/uploaduser.php 13 May 2009 05:35:38 -0000 1.68.2.15 +++ admin/uploaduser.php 17 Nov 2009 01:27:11 -0000 @@ -260,7 +260,7 @@ // normalize username $user->username = $textlib->strtolower($user->username); if (empty($CFG->extendedusernamechars)) { - $user->username = eregi_replace('[^(-\.[:alnum:])]', '', $user->username); + $user->username = preg_replace('/[^(-\.[:alnum:])]/i', '', $user->username); } if (empty($user->username)) { $upt->track('status', get_string('missingfield', 'error', 'username'), 'error'); Index: admin/mnet/MethodTable.php =================================================================== RCS file: /cvsroot/moodle/moodle/admin/mnet/MethodTable.php,v retrieving revision 1.1 diff -u -r1.1 MethodTable.php --- admin/mnet/MethodTable.php 4 Jan 2007 02:33:51 -0000 1.1 +++ admin/mnet/MethodTable.php 17 Nov 2009 01:27:11 -0000 @@ -465,9 +465,9 @@ $word0 = strtolower($word0); $word1 = strtolower($word1); - $wordBase0 = ereg_replace('^[&$]+','',$word0); - $wordBase1 = ereg_replace('^[&$]+','',$word1); - $startBase = strtolower(ereg_replace('^[&$]+','',$start)); + $wordBase0 = preg_replace('/^[&$]+/','',$word0); + $wordBase1 = preg_replace('/^[&$]+/','',$word1); + $startBase = strtolower(preg_replace('/^[&$]+/','',$start)); if ($wordBase0 == $startBase) { $type = str_replace(array('(',')'),'', $word1); @@ -535,7 +535,7 @@ $comment = str_replace("*/", "", $comment); $comment = str_replace("*", "", $comment); $comment = str_replace("\n", "\\n", trim($comment)); - $comment = eregi_replace("[\r\t\n ]+", " ", trim($comment)); + $comment = preg_replace("/[\r\t\n ]+/i", " ", trim($comment)); $comment = str_replace("\"", "\\\"", $comment); return $comment; } Index: auth/shibboleth/logout.php =================================================================== RCS file: /cvsroot/moodle/moodle/auth/shibboleth/logout.php,v retrieving revision 1.1.2.2 diff -u -r1.1.2.2 logout.php --- auth/shibboleth/logout.php 18 Mar 2009 13:26:31 -0000 1.1.2.2 +++ auth/shibboleth/logout.php 17 Nov 2009 01:27:26 -0000 @@ -139,7 +139,7 @@ while (($file = readdir($dh)) !== false) { // Check if it is a file if (is_file($dir.'/'.$file)){ - $session_key = ereg_replace('sess_', '', $file); + $session_key = preg_replace('/sess_/', '', $file); // Read session file data $data = file($dir.'/'.$file); Index: calendar/lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/calendar/lib.php,v retrieving revision 1.206.2.13 diff -u -r1.206.2.13 lib.php --- calendar/lib.php 30 Apr 2008 04:45:23 -0000 1.206.2.13 +++ calendar/lib.php 17 Nov 2009 01:28:02 -0000 @@ -766,8 +766,8 @@ $text = get_string('strftimedaydate'); /* // Regexp hackery to make a link out of the month/year part - $text = ereg_replace('(%B.+%Y|%Y.+%B|%Y.+%m[^ ]+)', '\\1', $text); - $text = ereg_replace('(F.+Y|Y.+F|Y.+m[^ ]+)', '\\1', $text); + $text = preg_replace('/(%B.+%Y|%Y.+%B|%Y.+%m[^ ]+)/', '\\1', $text); + $text = preg_replace('/(F.+Y|Y.+F|Y.+m[^ ]+)/', '\\1', $text); */ // Replace with actual values and lose any day leading zero $text = userdate($time, $text); Index: enrol/authorize/enrol_form.php =================================================================== RCS file: /cvsroot/moodle/moodle/enrol/authorize/enrol_form.php,v retrieving revision 1.16.2.5 diff -u -r1.16.2.5 enrol_form.php --- enrol/authorize/enrol_form.php 26 Sep 2009 16:28:53 -0000 1.16.2.5 +++ enrol/authorize/enrol_form.php 17 Nov 2009 01:28:21 -0000 @@ -276,7 +276,7 @@ $GoodCard = true; // Get rid of any non-digits - $Num = ereg_replace("[^0-9]", "", $Num); + $Num = preg_replace("/[^0-9]/", "", $Num); // Perform card-specific checks, if applicable switch ($Name) Index: filter/tex/filter.php =================================================================== RCS file: /cvsroot/moodle/moodle/filter/tex/filter.php,v retrieving revision 1.18.4.6 diff -u -r1.18.4.6 filter.php --- filter/tex/filter.php 31 Mar 2009 10:23:54 -0000 1.18.4.6 +++ filter/tex/filter.php 17 Nov 2009 01:28:24 -0000 @@ -146,7 +146,7 @@ $texexp = str_replace('','',$texexp); $texexp = str_replace('','',$texexp); $texexp = str_replace('','',$texexp); - $texexp = eregi_replace("", '', $texexp); //dlnsk + $texexp = preg_replace("##i", '', $texexp); //dlnsk $align = "middle"; if (preg_match('/^align=bottom /',$texexp)) { $align = "text-bottom"; Index: lib/moodlelib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/moodlelib.php,v retrieving revision 1.960.2.143 diff -u -r1.960.2.143 moodlelib.php --- lib/moodlelib.php 2 Nov 2009 16:50:33 -0000 1.960.2.143 +++ lib/moodlelib.php 17 Nov 2009 01:29:20 -0000 @@ -418,16 +418,16 @@ return (float)$param; // Convert to integer case PARAM_ALPHA: // Remove everything not a-z - return eregi_replace('[^a-zA-Z]', '', $param); + return reg_replace('/[^a-zA-Z]/i', '', $param); case PARAM_ALPHANUM: // Remove everything not a-zA-Z0-9 - return eregi_replace('[^A-Za-z0-9]', '', $param); + return preg_replace('/[^A-Za-z0-9]/i', '', $param); case PARAM_ALPHAEXT: // Remove everything not a-zA-Z/_- - return eregi_replace('[^a-zA-Z/_-]', '', $param); + return preg_replace('/[^a-zA-Z/_-]/i', '', $param); case PARAM_SEQUENCE: // Remove everything not 0-9, - return eregi_replace('[^0-9,]', '', $param); + return preg_replace('/[^0-9,]/i', '', $param); case PARAM_BOOL: // Convert to 1 or 0 $tempstr = strtolower($param); @@ -447,14 +447,14 @@ return clean_param(strip_tags($param, ''), PARAM_CLEAN); case PARAM_SAFEDIR: // Remove everything not a-zA-Z0-9_- - return eregi_replace('[^a-zA-Z0-9_-]', '', $param); + return preg_replace('/[^a-zA-Z0-9_-]/i', '', $param); case PARAM_CLEANFILE: // allow only safe characters return clean_filename($param); case PARAM_FILE: // Strip all suspicious characters from filename - $param = ereg_replace('[[:cntrl:]]|[<>"`\|\':\\/]', '', $param); - $param = ereg_replace('\.\.+', '', $param); + $param = preg_replace('/[[:cntrl:]]|[\/<>\"`|\':\\\\]/', '', $param); + $param = preg_replace('/\.\./', '', $param);//remove double full stops if($param == '.') { $param = ''; } @@ -464,10 +464,10 @@ $param = str_replace('\\\'', '\'', $param); $param = str_replace('\\"', '"', $param); $param = str_replace('\\', '/', $param); - $param = ereg_replace('[[:cntrl:]]|[<>"`\|\':]', '', $param); - $param = ereg_replace('\.\.+', '', $param); - $param = ereg_replace('//+', '/', $param); - return ereg_replace('/(\./)+', '/', $param); + $param = preg_replace('#[[:cntrl:]]|[<>"`\|\':]#', '', $param); + $param = preg_replace('#\.\.+#', '', $param); + $param = preg_replace('#//+#', '/', $param); + return preg_replace('#/(\./)+#', '/', $param); case PARAM_HOST: // allow FQDN or IPv4 dotted quad $param = preg_replace('/[^\.\d\w-]/','', $param ); // only allowed chars @@ -6807,7 +6807,7 @@ $textlib = textlib_get_instance(); $string = strip_tags($string); // Tags are out now - $string = ereg_replace('[[:space:]]*','',$string); //Whitespace are out now + $string = preg_replace('/[[:space:]]*/','',$string); //Whitespace are out now return $textlib->strlen($string); } @@ -7696,11 +7696,11 @@ //This function is used as callback in unzip_file() function //to clean illegal characters for given platform and to prevent directory traversal. //Produces the same result as info-zip unzip. - $p_header['filename'] = ereg_replace('[[:cntrl:]]', '', $p_header['filename']); //strip control chars first! - $p_header['filename'] = ereg_replace('\.\.+', '', $p_header['filename']); //directory traversal protection + $p_header['filename'] = preg_replace('/[[:cntrl:]]/', '', $p_header['filename']); //strip control chars first! + $p_header['filename'] = preg_replace('#\.\.+#', '', $p_header['filename']); //directory traversal protection if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - $p_header['filename'] = ereg_replace('[:*"?<>|]', '_', $p_header['filename']); //replace illegal chars - $p_header['filename'] = ereg_replace('^([a-zA-Z])_', '\1:', $p_header['filename']); //repair drive letter + $p_header['filename'] = preg_replace('/[:*"?<>|]/', '_', $p_header['filename']); //replace illegal chars + $p_header['filename'] = preg_replace('/^([a-zA-Z])_/', '\1:', $p_header['filename']); //repair drive letter } else { //Add filtering for other systems here // BSD: none (tested) Index: lib/weblib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/weblib.php,v retrieving revision 1.970.2.144 diff -u -r1.970.2.144 weblib.php --- lib/weblib.php 24 Sep 2009 02:15:12 -0000 1.970.2.144 +++ lib/weblib.php 17 Nov 2009 01:29:25 -0000 @@ -1791,7 +1791,7 @@ $text = wiki_to_html($text); /// This expression turns links into something nice in a text format. (Russell Jungwirth) /// From: http://php.net/manual/en/function.eregi-replace.php and simplified - $text = eregi_replace('(]*>([^<]*))','\\3 [ \\2 ]', $text); + $text = preg_replace('/(]*>([^<]*))/i','\\3 [ \\2 ]', $text); return strtr(strip_tags($text), array_flip(get_html_translation_table(HTML_ENTITIES))); break; @@ -1802,7 +1802,7 @@ case FORMAT_MOODLE: case FORMAT_MARKDOWN: default: - $text = eregi_replace('(]*>([^<]*))','\\3 [ \\2 ]', $text); + $text = preg_replace('/(]*>([^<]*))/i','\\3 [ \\2 ]', $text); return strtr(strip_tags($text), array_flip(get_html_translation_table(HTML_ENTITIES))); break; } @@ -2038,8 +2038,8 @@ } /// Remove potential script events - some extra protection for undiscovered bugs in our code - $text = eregi_replace("([^a-z])language([[:space:]]*)=", "\\1Xlanguage=", $text); - $text = eregi_replace("([^a-z])on([a-z]+)([[:space:]]*)=", "\\1Xon\\2=", $text); + $text = preg_replace("/([^a-z])language([[:space:]]*)=/i", "\\1Xlanguage=", $text); + $text = preg_replace("/([^a-z])on([a-z]+)([[:space:]]*)=/i", "\\1Xon\\2=", $text); return $text; } @@ -2238,11 +2238,11 @@ global $CFG; /// Remove any whitespace that may be between HTML tags - $text = eregi_replace(">([[:space:]]+)<", "><", $text); + $text = preg_replace("/>([[:space:]]+)<", $text); /// Remove any returns that precede or follow HTML tags - $text = eregi_replace("([\n\r])<", " <", $text); - $text = eregi_replace(">([\n\r])", "> ", $text); + $text = preg_replace("/([\n\r])([\n\r])/i", "> ", $text); convert_urls_into_links($text); @@ -2305,11 +2305,11 @@ */ function convert_urls_into_links(&$text) { /// Make lone URLs into links. eg http://moodle.com/ - $text = eregi_replace("([[:space:]]|^|\(|\[)([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])", + $text = preg_replace("#([[:space:]]|^|\(|\[)([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]\#?/&=])#i", "\\1\\2://\\3\\4", $text); /// eg www.moodle.com - $text = eregi_replace("([[:space:]]|^|\(|\[)www\.([^[:space:]]*)([[:alnum:]#?/&=])", + $text = preg_replace("#([[:space:]]|^|\(|\[)www\.([^[:space:]]*)([[:alnum:]\#?/&=])#i", "\\1www.\\2\\3", $text); } Index: lib/wiki_to_markdown.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/wiki_to_markdown.php,v retrieving revision 1.11.18.1 diff -u -r1.11.18.1 wiki_to_markdown.php --- lib/wiki_to_markdown.php 10 Jul 2008 09:48:45 -0000 1.11.18.1 +++ lib/wiki_to_markdown.php 17 Nov 2009 01:29:26 -0000 @@ -59,14 +59,14 @@ // BODGE: replace inline $mark characters in places where we want them ignored // they will be put back after main substitutue, stops problems with eg, and/or $bodge = chr(1); - $line = eregi_replace( '([[:alnum:]])'.$mark.'([[:alnum:]])', '\\1'.$bodge.'\\2',$line ); + $line = preg_replace( '/([[:alnum:]])'.$mark.'([[:alnum:]])/i', '\\1'.$bodge.'\\2',$line ); - $regex = '(^| |[(.,])'.$mark.'([^'.$mark.']*)'.$mark.'([^[:alnum:]]|$)'; + $regex = '/(^| |[(.,])'.$mark.'([^'.$mark.']*)'.$mark.'([^[:alnum:]]|$)/i'; $replace = '\\1<'.$tag.'>\\2\\3'; - $line = eregi_replace( $regex, $replace, $line ); + $line = preg_replace( $regex, $replace, $line ); // BODGE: back we go - $line = eregi_replace( $bodge, $mark, $line ); + $line = preg_replace( '/'.$bodge.'/i', $mark, $line ); return $line; } @@ -80,14 +80,14 @@ // BODGE: replace inline $mark characters in places where we want them ignored // they will be put back after main substitutue, stops problems with eg, and/or $bodge = chr(1); - $line = eregi_replace( '([[:alnum:]])'.$mark.'([[:alnum:]])', '\\1'.$bodge.'\\2',$line ); + $line = preg_replace( '/([[:alnum:]])'.$mark.'([[:alnum:]])/i', '\\1'.$bodge.'\\2',$line ); - $regex = '(^| |[(.,])'.$mark.'([^'.$mark.']*)'.$mark.'([^[:alnum:]]|$)'; + $regex = '/(^| |[(.,])'.$mark.'([^'.$mark.']*)'.$mark.'([^[:alnum:]]|$)/i'; $replace = '\\1'.$tag.'\\2'.$tag.'\\3'; - $line = eregi_replace( $regex, $replace, $line ); + $line = preg_replace( $regex, $replace, $line ); // BODGE: back we go - $line = eregi_replace( $bodge, $mark, $line ); + $line = preg_replace( '/'.$bodge.'/i', $mark, $line ); return $line; } @@ -97,10 +97,10 @@ // do regex for subscript and superscript (slightly different) // $mark is the magic character and $tag the HTML tag to insert - $regex = $mark.'([^'.$mark.']*)'.$mark; + $regex = '/'.$mark.'([^'.$mark.']*)'.$mark.'/i'; $replace = '<'.$tag.'>\\1'; - return eregi_replace( $regex, $replace, $line ); + return preg_replace( $regex, $replace, $line ); } function do_list( $line, $blank=false ) { @@ -115,7 +115,7 @@ else { $listchar = $line{0}; $count = strspn( $line, $listchar ); - $line = eregi_replace( "^[".$listchar."]+ ", "", $line ); + $line = preg_replace( "/^[".$listchar."]+ /i", "", $line ); } // find what sort of list this character represents @@ -215,7 +215,7 @@ $line = str_replace( "1/4", "¼", $line ); $line = str_replace( "1/2", "½", $line ); $line = str_replace( "3/4", "¾", $line ); - $line = eregi_replace( "([[:digit:]]+[[:space:]]*)x([[:space:]]*[[:digit:]]+)", "\\1×\\2", $line ); // (digits) x (digits) - multiply + $line = preg_replace( "/([[:digit:]]+[[:space:]]*)x([[:space:]]*[[:digit:]]+)/i", "\\1×\\2", $line ); // (digits) x (digits) - multiply // do formatting tags // NOTE: The / replacement *has* to be first, or it will screw the // HTML tags that are added by the other ones @@ -231,48 +231,48 @@ // convert urls into proper link with optional link text URL(text) // MARDOWN: HTML conversion should work fine - $line = eregi_replace("([[:space:]]|^)([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])\(([^)]+)\)", + $line = preg_replace("#([[:space:]]|^)([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]\#?/&=])\(([^)]+)\)#i", "\\1[\\5](\\2://\\3\\4)", $line); - $line = eregi_replace("([[:space:]])www\.([^[:space:]]*)([[:alnum:]#?/&=])\(([^)]+)\)", + $line = preg_replace("/([[:space:]])www\.([^[:space:]]*)([[:alnum:]#?\/&=])\(([^)]+)\)/i", "\\1[\\5](http://www.\\2\\3)", $line); // make urls (with and without httpd) into proper links - $line = eregi_replace("([[:space:]]|^)([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])", + $line = preg_replace("#([[:space:]]|^)([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]\#?/&=])#i", "\\1<\\2://\\3\\4>", $line); - $line = eregi_replace("([[:space:]])www\.([^[:space:]]*)([[:alnum:]#?/&=])", + $line = preg_replace("/([[:space:]])www\.([^[:space:]]*)([[:alnum:]#?/&=])/i", "\\1", $line); // make email addresses into mailtos.... // MARKDOWN doesn't quite support this, so do as html - $line = eregi_replace("([[:space:]]|^)([[:alnum:]._-]+@[[:alnum:]._-]+)\(([^)]+)\)", + $line = preg_replace("/([[:space:]]|^)([[:alnum:]._-]+@[[:alnum:]._-]+)\(([^)]+)\)/i", "\\1\\3", $line); // !# at the beginning of any lines means a heading // MARKDOWN: value (1-6) becomes number of hashes - if (eregi( "^!([1-6]) (.*)$", $line, $regs )) { + if (preg( "/^!([1-6]) (.*)$/i", $line, $regs )) { $depth = substr( $line, 1, 1 ); $out = substr( '##########', 0, $depth); - $line = eregi_replace( "^!([1-6]) (.*)$", "$out \\2", $line ); + $line = preg_replace( "/^!([1-6]) (.*)$/i", "$out \\2", $line ); } // acronym handing, example HTML(Hypertext Markyp Language) // MARKDOWN: no equiv. so just leave as HTML - $line = ereg_replace( "([A-Z]+)\(([^)]+)\)", "\\1", $line ); + $line = preg_replace( "/([A-Z]+)\(([^)]+)\)/", "\\1", $line ); // Replace resource link >>##(Description Text) // MARKDOWN: change to MD web link style - $line = eregi_replace( " ([a-zA-Z]+):([0-9]+)\(([^)]+)\)", + $line = preg_replace( "/ ([a-zA-Z]+):([0-9]+)\(([^)]+)\)/i", " [\\3](".$CFG->wwwroot."/mod/\\1/view.php?id=\\2) ", $line ); require_once($CFG->libdir.'/filelib.php'); $coursefileurl = get_file_url($this->courseid); // Replace picture resource link - $line = eregi_replace( "/([a-zA-Z0-9./_-]+)(png|gif|jpg)\(([^)]+)\)", + $line = preg_replace( "#/([a-zA-Z0-9./_-]+)(png|gif|jpg)\(([^)]+)\)#i", "![\\3](".$coursefileurl."/\\1\\2)", $line ); // Replace file resource link - $line = eregi_replace( "file:/([[:alnum:]/._-]+)\(([^)]+)\)", + $line = preg_replace( "#file:/([[:alnum:]/._-]+)\(([^)]+)\)#i", "[\\2](".$coursefileurl."/\\1)", $line ); return $line; @@ -328,7 +328,7 @@ if (eregi("^\% ",$line) ) { // preformatted text - no processing // MARKDOWN: this is MD code form of a paragraph - $buffer = $buffer . " " . eregi_replace( "^\%","",$line) . "\n"; + $buffer = $buffer . " " . preg_replace( "/^\%/i","",$line) . "\n"; $this->block_state = STATE_NOTIKI; } else { Index: lib/htmlpurifier/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 --- lib/htmlpurifier/HTMLPurifier/AttrDef/Lang.php 25 Sep 2007 14:34:13 -0000 1.3 +++ lib/htmlpurifier/HTMLPurifier/AttrDef/Lang.php 17 Nov 2009 01:30:01 -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); Index: lib/simpletest/testmoodlelib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/simpletest/testmoodlelib.php,v retrieving revision 1.9.2.6 diff -u -r1.9.2.6 testmoodlelib.php --- lib/simpletest/testmoodlelib.php 23 Oct 2009 15:10:50 -0000 1.9.2.6 +++ lib/simpletest/testmoodlelib.php 17 Nov 2009 01:30:12 -0000 @@ -199,6 +199,17 @@ $this->assertEqual(clean_param($CFG->wwwroot, PARAM_LOCALURL), $CFG->wwwroot); $this->assertEqual(clean_param('/just/a/path', PARAM_LOCALURL), '/just/a/path'); $this->assertEqual(clean_param('funny:thing', PARAM_LOCALURL), ''); + + //test filename param + $this->assertEqual(clean_param('correctfile.txt', PARAM_FILE), 'correctfile.txt'); + $this->assertEqual(clean_param('b\'ae.t"x|t', PARAM_FILE), 'badfile.txt'); + $this->assertEqual(clean_param('../parentdirfile.txt', PARAM_FILE), 'parentdirfile.txt'); + //The following behaviours have been maintained although they seem a little odd + $this->assertEqual(clean_param('funny:thing', PARAM_FILE), 'funnything'); + $this->assertEqual(clean_param('./currentdirfile.txt', PARAM_FILE), '.currentdirfile.txt'); + $this->assertEqual(clean_param('c:\temp\windowsfile.txt', PARAM_FILE), 'ctempwindowsfile.txt'); + $this->assertEqual(clean_param('/home/user/linuxfile.txt', PARAM_FILE), 'homeuserlinuxfile.txt'); + $this->assertEqual(clean_param('~/myfile.txt', PARAM_FILE), '~myfile.txt'); } function test_make_user_directory() { Index: lib/typo3/class.t3lib_cs.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/typo3/class.t3lib_cs.php,v retrieving revision 1.7 diff -u -r1.7 class.t3lib_cs.php --- lib/typo3/class.t3lib_cs.php 11 Aug 2006 09:48:35 -0000 1.7 +++ lib/typo3/class.t3lib_cs.php 17 Nov 2009 01:31:24 -0000 @@ -781,8 +781,8 @@ $trans_tbl = array_flip(get_html_translation_table(HTML_ENTITIES)); // Getting them in iso-8859-1 - but thats ok since this is observed below. } - $token = md5(microtime()); - $parts = explode($token,ereg_replace('(&([#[:alnum:]]*);)',$token.'\2'.$token,$str)); + $token = 'a'.md5(microtime());//token must start with a letter or preg_replace substitution won't work + $parts = explode($token,preg_replace('/(&([#[:alnum:]]*);)/',$token.'\2'.$token,$str)); foreach($parts as $k => $v) { if ($k%2) { if (substr($v,0,1)=='#') { // Dec or hex entities: Index: lib/typo3/class.t3lib_div.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/typo3/class.t3lib_div.php,v retrieving revision 1.2 diff -u -r1.2 class.t3lib_div.php --- lib/typo3/class.t3lib_div.php 17 Oct 2005 15:48:29 -0000 1.2 +++ lib/typo3/class.t3lib_div.php 17 Nov 2009 01:31:33 -0000 @@ -882,7 +882,7 @@ * @return string */ function rm_endcomma($string) { - return ereg_replace(',$','',$string); + return preg_replace('/,$/','',$string); } /** @@ -896,7 +896,7 @@ */ function danish_strtoupper($string) { $value = strtoupper($string); - return strtr($value, 'áéúíâêûôîæøåäöü', 'ÁÉÚÍÄËÜÖÏÆØÅÄÖÜ'); + return strtr($value, '���������������', '���������������'); } /** @@ -904,13 +904,13 @@ * Only known characters will be converted, so don't expect a result for any character. * (DEPRECIATED: Works only for western europe single-byte charsets! Use t3lib_cs::specCharsToASCII() instead!) * - * ä => ae, Ö => Oe + * � => ae, � => Oe * * @param string String to convert. * @return string */ function convUmlauts($str) { - $pat = array ( '/ä/', '/Ä/', '/ö/', '/Ö/', '/ü/', '/Ü/', '/ß/', '/å/', '/Å/', '/ø/', '/Ø/', '/æ/', '/Æ/' ); + $pat = array ( '/�/', '/�/', '/�/', '/�/', '/�/', '/�/', '/�/', '/�/', '/�/', '/�/', '/�/', '/�/', '/�/' ); $repl = array ( 'ae', 'Ae', 'oe', 'Oe', 'ue', 'Ue', 'ss', 'aa', 'AA', 'oe', 'OE', 'ae', 'AE' ); return preg_replace($pat,$repl,$str); } @@ -1022,7 +1022,7 @@ * @see calcParenthesis() */ function calcPriority($string) { - $string=ereg_replace('[[:space:]]*','',$string); // removing all whitespace + $string=preg_replace('/[ ]*/','',$string); // removing all whitespace $string='+'.$string; // Ensuring an operator for the first entrance $qm='\*\/\+-^%'; $regex = '(['.$qm.'])(['.$qm.']?[0-9\.]*)'; @@ -1103,7 +1103,7 @@ * @return string Converted result. */ function deHSCentities($str) { - return ereg_replace('&([#[:alnum:]]*;)','&\1',$str); + return preg_replace('/&([#A-Za-z0-9]*;)/','&\1',$str); } /** @@ -1555,7 +1555,7 @@ $name = ''; } } else { - if ($key = strtolower(ereg_replace('[^a-zA-Z0-9]','',$val))) { + if ($key = strtolower(preg_replace('/[^a-zA-Z0-9]/','',$val))) { $attributes[$key] = ''; $name = $key; } @@ -1580,9 +1580,9 @@ * @internal */ function split_tag_attributes($tag) { - $tag_tmp = trim(eregi_replace ('^<[^[:space:]]*','',trim($tag))); + $tag_tmp = trim(preg_replace ('/^<[^[:space:]]*/i','',trim($tag))); // Removes any > in the end of the string - $tag_tmp = trim(eregi_replace ('>$','',$tag_tmp)); + $tag_tmp = trim(preg_replace ('/>$/i','',$tag_tmp)); while (strcmp($tag_tmp,'')) { // Compared with empty string instead , 030102 $firstChar=substr($tag_tmp,0,1); @@ -1653,7 +1653,7 @@ * @param boolean Wrap script element in linebreaks? Default is TRUE. * @return string The wrapped JS code, ready to put into a XHTML page * @author Ingmar Schlecht - * @author René Fritz + * @author Ren� Fritz */ function wrapJS($string, $linebreak=TRUE) { if(trim($string)) { @@ -1813,7 +1813,7 @@ } // The tag name is cleaned up so only alphanumeric chars (plus - and _) are in there and not longer than 100 chars either. - $tagName = substr(ereg_replace('[^[:alnum:]_-]','',$tagName),0,100); + $tagName = substr(preg_replace('/[^[:alnum:]_-]/','',$tagName),0,100); // If the value is an array then we will call this function recursively: if (is_array($v)) { @@ -2191,7 +2191,7 @@ * @return boolean TRUE if @mkdir went well! */ function mkdir($theNewFolder) { - $theNewFolder = ereg_replace('\/$','',$theNewFolder); + $theNewFolder = preg_replace('#\/$#','',$theNewFolder); if (mkdir($theNewFolder, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask']))){ chmod($theNewFolder, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'])); //added this line, because the mode at 'mkdir' has a strange behaviour sometimes @@ -2240,7 +2240,7 @@ // Initialize variabels: $filearray = array(); $sortarray = array(); - $path = ereg_replace('\/$','',$path); + $path = preg_replace('#\/$#','',$path); // Find files+directories: if (@is_dir($path)) { @@ -2564,7 +2564,7 @@ $pString = t3lib_div::implodeArrayForUrl('',$params); - return $pString ? $parts.'?'.ereg_replace('^&','',$pString) : $parts; + return $pString ? $parts.'?'.preg_replace('/^&/','',$pString) : $parts; } /** @@ -2673,7 +2673,7 @@ case 'REQUEST_URI': // Typical application of REQUEST_URI is return urls, forms submitting to itself etc. Example: returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) if (!$_SERVER['REQUEST_URI']) { // This is for ISS/CGI which does not have the REQUEST_URI available. - return '/'.ereg_replace('^/','',t3lib_div::getIndpEnv('SCRIPT_NAME')). + return '/'.preg_replace('#^/#','',t3lib_div::getIndpEnv('SCRIPT_NAME')). ($_SERVER['QUERY_STRING']?'?'.$_SERVER['QUERY_STRING']:''); } else return $_SERVER['REQUEST_URI']; break; @@ -2826,11 +2826,11 @@ break; case 'msie': $tmp = strstr($useragent,'MSIE'); - $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,4))); + $bInfo['VERSION'] = doubleval(preg_replace('/^[^0-9]*/','',substr($tmp,4))); break; case 'opera': $tmp = strstr($useragent,'Opera'); - $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,5))); + $bInfo['VERSION'] = doubleval(preg_replace('/^[^0-9]*/','',substr($tmp,5))); break; case 'konqu': $tmp = strstr($useragent,'Konqueror/'); @@ -3126,7 +3126,7 @@ function readLLfile($fileRef,$langKey) { $file = t3lib_div::getFileAbsFileName($fileRef); if ($file) { - $baseFile = ereg_replace('\.(php|xml)$', '', $file); + $baseFile = preg_replace('#\.(php|xml)$#', '', $file); if (@is_file($baseFile.'.xml')) { $LOCAL_LANG = t3lib_div::readLLXMLfile($baseFile.'.xml', $langKey); @@ -3162,7 +3162,7 @@ // Cache file name: $hashSource = substr($fileRef,strlen(PATH_site)).'|'.date('d-m-Y H:i:s',filemtime($fileRef)); $cacheFileName = PATH_site.'typo3temp/llxml/'. - #str_replace('_','',ereg_replace('^.*\/','',dirname($fileRef))). + #str_replace('_','',preg_replace('#^.*\/#','',dirname($fileRef))). #'_'.basename($fileRef). substr(basename($fileRef),10,15). '_'.t3lib_div::shortMD5($hashSource).'.'.$langKey.'.'.$origCharset.'.cache'; @@ -3520,7 +3520,7 @@ * @param string Sub type like file extensions or similar. Defined by the service. * @param mixed List of service keys which should be exluded in the search for a service. Array or comma list. * @return object The service object or an array with error info's. - * @author René Fritz + * @author Ren� Fritz */ function &makeInstanceService($serviceType, $serviceSubType='', $excludeServiceKeys=array()) { global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS; @@ -3606,7 +3606,7 @@ $message=t3lib_div::quoted_printable($message); - if (!$dontEncodeSubject) $subject='=?'.$charset.'?Q?'.trim(t3lib_div::quoted_printable(ereg_replace('[[:space:]]','_',$subject),1000)).'?='; + if (!$dontEncodeSubject) $subject='=?'.$charset.'?Q?'.trim(t3lib_div::quoted_printable(preg_replace('#/[[:space:]]/#','_',$subject),1000)).'?='; break; case '8bit': $headers=trim($headers).chr(10). @@ -3657,11 +3657,11 @@ $len+=3; } } - $newVal = ereg_replace(chr(32).'$','=20',$newVal); // Replaces a possible SPACE-character at the end of a line - $newVal = ereg_replace(chr(9).'$','=09',$newVal); // Replaces a possible TAB-character at the end of a line + $newVal = preg_replace('/'.chr(32).'$/','=20',$newVal); // Replaces a possible SPACE-character at the end of a line + $newVal = preg_replace('/'.chr(9).'$/','=09',$newVal); // Replaces a possible TAB-character at the end of a line $newString.=$newVal.chr(13).chr(10); } - return ereg_replace(chr(13).chr(10).'$','',$newString); + return preg_replace('/'.chr(13).chr(10).'$/','',$newString); } /** Index: lib/xmldb/classes/XMLDBObject.class.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/xmldb/classes/Attic/XMLDBObject.class.php,v retrieving revision 1.7.2.1 diff -u -r1.7.2.1 XMLDBObject.class.php --- lib/xmldb/classes/XMLDBObject.class.php 15 Aug 2008 11:09:51 -0000 1.7.2.1 +++ lib/xmldb/classes/XMLDBObject.class.php 17 Nov 2009 01:31:34 -0000 @@ -164,7 +164,7 @@ function checkName () { $result = true; - if ($this->name != eregi_replace('[^a-z0-9_ -]', '', $this->name)) { + if ($this->name != preg_replace('/[^a-z0-9_ -]/i', '', $this->name)) { $result = false; } return $result; Index: login/index.php =================================================================== RCS file: /cvsroot/moodle/moodle/login/index.php,v retrieving revision 1.129.2.6 diff -u -r1.129.2.6 index.php --- login/index.php 3 Jun 2009 14:22:19 -0000 1.129.2.6 +++ login/index.php 17 Nov 2009 01:38:00 -0000 @@ -109,7 +109,7 @@ $frm->username = trim(moodle_strtolower($frm->username)); if (is_enabled_auth('none') && empty($CFG->extendedusernamechars)) { - $string = eregi_replace("[^(-\.[:alnum:])]", "", $frm->username); + $string = preg_replace("/[^(-\.[:alnum:])]/i", "", $frm->username); if (strcmp($frm->username, $string)) { $errormsg = get_string('username').': '.get_string("alphanumerical"); $errorcode = 2; Index: login/signup_form.php =================================================================== RCS file: /cvsroot/moodle/moodle/login/signup_form.php,v retrieving revision 1.35.2.6 diff -u -r1.35.2.6 signup_form.php --- login/signup_form.php 23 Jul 2008 05:21:21 -0000 1.35.2.6 +++ login/signup_form.php 17 Nov 2009 01:38:00 -0000 @@ -99,7 +99,7 @@ $errors['username'] = get_string('usernameexists'); } else { if (empty($CFG->extendedusernamechars)) { - $string = eregi_replace("[^(-\.[:alnum:])]", '', $data['username']); + $string = preg_replace("/[^(-\.[:alnum:])]/i", '', $data['username']); if (strcmp($data['username'], $string)) { $errors['username'] = get_string('alphanumerical'); } Index: mnet/lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mnet/lib.php,v retrieving revision 1.16.2.10 diff -u -r1.16.2.10 lib.php --- mnet/lib.php 11 Sep 2009 10:06:28 -0000 1.16.2.10 +++ mnet/lib.php 17 Nov 2009 01:38:02 -0000 @@ -314,7 +314,7 @@ } $host = strtolower($CFG->wwwroot); - $host = ereg_replace("^http(s)?://",'',$host); + $host = preg_replace("#^http(s)?://#",'',$host); $break = strpos($host.'/' , '/'); $host = substr($host, 0, $break); Index: mod/scorm/player.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/scorm/player.php,v retrieving revision 1.34.2.9 diff -u -r1.34.2.9 player.php --- mod/scorm/player.php 14 Nov 2008 00:14:50 -0000 1.34.2.9 +++ mod/scorm/player.php 17 Nov 2009 01:39:16 -0000 @@ -281,7 +281,7 @@ echo " \n"; } else { // Clean the name for the window as IE is fussy - $name = ereg_replace("[^A-Za-z0-9]", "", $scorm->name); + $name = preg_replace("/[^A-Za-z0-9]/", "", $scorm->name); if (!$name) { $name = 'DefaultPlayerWindow'; } Index: mod/scorm/datamodels/aicclib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/scorm/datamodels/aicclib.php,v retrieving revision 1.5.2.9 diff -u -r1.5.2.9 aicclib.php --- mod/scorm/datamodels/aicclib.php 22 Dec 2008 07:04:37 -0000 1.5.2.9 +++ mod/scorm/datamodels/aicclib.php 17 Nov 2009 01:39:17 -0000 @@ -281,7 +281,7 @@ } if (isset($element->core_vendor)) { $scodata->name = 'datafromlms'; - $scodata->value = eregi_replace('', "\r\n", $element->core_vendor); + $scodata->value = preg_replace('//i', "\r\n", $element->core_vendor); $dataid = insert_record('scorm_scoes_data',$scodata); } } Index: mod/wiki/lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/wiki/lib.php,v retrieving revision 1.53.2.6 diff -u -r1.53.2.6 lib.php --- mod/wiki/lib.php 22 Apr 2009 21:29:23 -0000 1.53.2.6 +++ mod/wiki/lib.php 17 Nov 2009 01:39:24 -0000 @@ -1569,11 +1569,11 @@ } /// Remove old Notices - $content = eregi_replace(' µµ__~\['.get_string("offline","wiki").'\]__µµ ','', $content); + $content = preg_replace('/ µµ__~\['.get_string("offline","wiki").'\]__µµ /i','', $content); #-- replace dead links foreach ($badlinks as $href) { - $content = preg_replace("\377^(.*)($href)\377m", '$1 µµ__~['.get_string("offline","wiki").']__µµ $2', $content); + $content = preg_replace("/\377^(.*)($href)\377m", '$1 µµ__~['.get_string("offline","wiki").']__µµ $2/', $content); } #-- compare against db content Index: pix/smartpix.php =================================================================== RCS file: /cvsroot/moodle/moodle/pix/smartpix.php,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 smartpix.php --- pix/smartpix.php 4 Mar 2009 11:55:19 -0000 1.1.4.2 +++ pix/smartpix.php 17 Nov 2009 01:39:38 -0000 @@ -21,10 +21,10 @@ $param = str_replace('\\\'', '\'', $param); $param = str_replace('\\"', '"', $param); $param = str_replace('\\', '/', $param); - $param = ereg_replace('[[:cntrl:]]|[<>"`\|\':]', '', $param); - $param = ereg_replace('\.\.+', '', $param); - $param = ereg_replace('//+', '/', $param); - return ereg_replace('/(\./)+', '/', $param); + $param = preg_replace('/[[:cntrl:]]|[<>"`\|\':]/', '', $param); + $param = preg_replace('/\.\.+/', '', $param); + $param = preg_replace('#//+#', '/', $param); + return preg_replace('#/(\./)+#', '/', $param); } // Nicked from weblib Index: question/format.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/format.php,v retrieving revision 1.35.2.13 diff -u -r1.35.2.13 format.php --- question/format.php 30 Sep 2009 13:38:51 -0000 1.35.2.13 +++ question/format.php 17 Nov 2009 01:39:41 -0000 @@ -583,7 +583,7 @@ fclose( $fh ); // return the (possibly) new filename - $newfile = ereg_replace("{$CFG->dataroot}/{$this->course->id}/", '',$newfullpath); + $newfile = preg_replace("#{$CFG->dataroot}/{$this->course->id}/#", '',$newfullpath); return $newfile; } Index: question/format/qti2/format.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/format/qti2/Attic/format.php,v retrieving revision 1.12.4.3 diff -u -r1.12.4.3 format.php --- question/format/qti2/format.php 4 Aug 2008 10:07:54 -0000 1.12.4.3 +++ question/format/qti2/format.php 17 Nov 2009 01:39:45 -0000 @@ -33,8 +33,8 @@ // Remove all tabs. $source = str_replace("\t", '', $source); // Remove all space after ">" and before "<". - $source = ereg_replace(">( )*", ">", $source); - $source = ereg_replace("( )*<", "<", $source); + $source = preg_replace("/>( )*/", ">", $source); + $source = preg_replace("/( )*qtype ) && CALCULATED == $question->qtype && ereg( "^:([[:lower:]].*|::.*)-(MIN|MAX|DEC|VAL([0-9]+))::?:?($webctnumberregex)", $line, $webct_options)) { - $datasetname = ereg_replace('^::', '', $webct_options[1]); + $datasetname = preg_replace('/^::/', '', $webct_options[1]); $datasetvalue = qformat_webct_convert_formula($webct_options[4]); switch ($webct_options[2]) { case 'MIN': Index: question/format/xml/format.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/format/xml/format.php,v retrieving revision 1.41.2.11 diff -u -r1.41.2.11 format.php --- question/format/xml/format.php 30 Sep 2009 13:38:51 -0000 1.41.2.11 +++ question/format/xml/format.php 17 Nov 2009 01:39:47 -0000 @@ -921,9 +921,9 @@ case MULTIANSWER: $a_count=1; foreach($question->options->questions as $question) { - $thispattern = addslashes("{#".$a_count."}"); + $thispattern = '/'.addslashes("{#".$a_count."}").'/'; $thisreplace = $question->questiontext; - $expout=ereg_replace($thispattern, $thisreplace, $expout ); + $expout=preg_replace($thispattern, $thisreplace, $expout ); $a_count++; } break; Index: question/type/calculated/questiontype.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/type/calculated/questiontype.php,v retrieving revision 1.26.2.15 diff -u -r1.26.2.15 questiontype.php --- question/type/calculated/questiontype.php 25 May 2009 03:35:23 -0000 1.26.2.15 +++ question/type/calculated/questiontype.php 17 Nov 2009 01:39:49 -0000 @@ -1328,7 +1328,7 @@ $formula = str_replace($regs[0], $regs[1] . '1', $formula); } else { // The function call starts the formula - $formula = ereg_replace("^$regs[2]\\([^)]*\\)", '1', $formula); + $formula = preg_replace("/^$regs[2]\\([^)]*\\)/", '1', $formula); } } Index: user/editadvanced_form.php =================================================================== RCS file: /cvsroot/moodle/moodle/user/editadvanced_form.php,v retrieving revision 1.14.2.14 diff -u -r1.14.2.14 editadvanced_form.php --- user/editadvanced_form.php 27 Sep 2009 19:13:22 -0000 1.14.2.14 +++ user/editadvanced_form.php 17 Nov 2009 01:40:41 -0000 @@ -143,7 +143,7 @@ $err['username'] = get_string('usernamelowercase'); } else { if (empty($CFG->extendedusernamechars)) { - $string = eregi_replace("[^(-\.[:alnum:])]", '', $usernew->username); + $string = preg_replace("/[^(-\.[:alnum:])]/i", '', $usernew->username); if ($usernew->username !== $string) { $err['username'] = get_string('alphanumerical'); }