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

This commit is contained in:
Petr Skoda
2009-11-19 09:56:52 +00:00
parent 199be8868e
commit 59fa78efa4
7 changed files with 22 additions and 22 deletions
+2 -2
View File
@@ -766,8 +766,8 @@ function calendar_top_controls($type, $data) {
$text = get_string('strftimedaydate');
/*
// Regexp hackery to make a link out of the month/year part
$text = preg_replace('/(%B.+%Y|%Y.+%B|%Y.+%m[^ ]+)/', '<a href="'.calendar_get_link_href('view.php?view=month&amp;', 1, $data['m'], $data['y']).'">\\1</a>', $text);
$text = preg_replace('/(F.+Y|Y.+F|Y.+m[^ ]+)/', '<a href="'.calendar_get_link_href('view.php?view=month&amp;', 1, $data['m'], $data['y']).'">\\1</a>', $text);
$text = ereg_replace('(%B.+%Y|%Y.+%B|%Y.+%m[^ ]+)', '<a href="'.calendar_get_link_href('view.php?view=month&amp;', 1, $data['m'], $data['y']).'">\\1</a>', $text);
$text = ereg_replace('(F.+Y|Y.+F|Y.+m[^ ]+)', '<a href="'.calendar_get_link_href('view.php?view=month&amp;', 1, $data['m'], $data['y']).'">\\1</a>', $text);
*/
// Replace with actual values and lose any day leading zero
$text = userdate($time, $text);
+2 -2
View File
@@ -1264,10 +1264,10 @@ class Worksheet extends BIFFwriter
}
// Strip the '=' or '@' sign at the beginning of the formula string
if (preg_match("/^=/",$formula)) {
if (ereg("^=",$formula)) {
$formula = preg_replace("/(^=)/","",$formula);
}
elseif(preg_match("/^@/",$formula)) {
elseif(ereg("^@",$formula)) {
$formula = preg_replace("/(^@)/","",$formula);
}
else {
+13 -13
View File
@@ -1355,11 +1355,11 @@ function formerr($error) {
*/
function validate_email($address) {
return (preg_match('#^[-!\#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+'.
'(\.[-!\#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+)*'.
return (ereg('^[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+'.
'(\.[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+)*'.
'@'.
'[-!\#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.
'[-!\#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$#',
'[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.
'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$',
$address));
}
@@ -1791,7 +1791,7 @@ function format_text_email($text, $format) {
$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 = preg_replace('/(<a [^<]*href=["|\']?([^ "\']*)["|\']?[^>]*>([^<]*)</a>)/i','\\3 [ \\2 ]', $text);
$text = eregi_replace('(<a [^<]*href=["|\']?([^ "\']*)["|\']?[^>]*>([^<]*)</a>)','\\3 [ \\2 ]', $text);
return strtr(strip_tags($text), array_flip(get_html_translation_table(HTML_ENTITIES)));
break;
@@ -1802,7 +1802,7 @@ function format_text_email($text, $format) {
case FORMAT_MOODLE:
case FORMAT_MARKDOWN:
default:
$text = preg_replace('/(<a [^<]*href=["|\']?([^ "\']*)["|\']?[^>]*>([^<]*)</a>)/i','\\3 [ \\2 ]', $text);
$text = eregi_replace('(<a [^<]*href=["|\']?([^ "\']*)["|\']?[^>]*>([^<]*)</a>)','\\3 [ \\2 ]', $text);
return strtr(strip_tags($text), array_flip(get_html_translation_table(HTML_ENTITIES)));
break;
}
@@ -2038,8 +2038,8 @@ function clean_text($text, $format=FORMAT_MOODLE) {
}
/// Remove potential script events - some extra protection for undiscovered bugs in our code
$text = preg_replace("/([^a-z])language([[:space:]]*)=/i", "\\1Xlanguage=", $text);
$text = preg_replace("/([^a-z])on([a-z]+)([[:space:]]*)=/i", "\\1Xon\\2=", $text);
$text = eregi_replace("([^a-z])language([[:space:]]*)=", "\\1Xlanguage=", $text);
$text = eregi_replace("([^a-z])on([a-z]+)([[:space:]]*)=", "\\1Xon\\2=", $text);
return $text;
}
@@ -2238,11 +2238,11 @@ function text_to_html($text, $smiley=true, $para=true, $newlines=true) {
global $CFG;
/// Remove any whitespace that may be between HTML tags
$text = preg_replace("/>([[:space:]]+)</i", "><", $text);
$text = eregi_replace(">([[:space:]]+)<", "><", $text);
/// Remove any returns that precede or follow HTML tags
$text = preg_replace("/([\n\r])</i", " <", $text);
$text = preg_replace("/>([\n\r])/i", "> ", $text);
$text = eregi_replace("([\n\r])<", " <", $text);
$text = eregi_replace(">([\n\r])", "> ", $text);
convert_urls_into_links($text);
@@ -2305,11 +2305,11 @@ function html_to_text($html) {
*/
function convert_urls_into_links(&$text) {
/// Make lone URLs into links. eg http://moodle.com/
$text = preg_replace("#([[:space:]]|^|\(|\[)([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]\#?/&=])#i",
$text = eregi_replace("([[:space:]]|^|\(|\[)([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])",
"\\1<a href=\"\\2://\\3\\4\" target=\"_blank\">\\2://\\3\\4</a>", $text);
/// eg www.moodle.com
$text = preg_replace("#([[:space:]]|^|\(|\[)www\.([^[:space:]]*)([[:alnum:]\#?/&=])#i",
$text = eregi_replace("([[:space:]]|^|\(|\[)www\.([^[:space:]]*)([[:alnum:]#?/&=])",
"\\1<a href=\"http://www.\\2\\3\" target=\"_blank\">www.\\2\\3</a>", $text);
}
+1 -1
View File
@@ -180,7 +180,7 @@ class qformat_blackboard_6 extends qformat_default {
if (is_readable($q_file)) {
$filearray = file($q_file);
/// Check for Macintosh OS line returns (ie file on one line), and fix
if (preg_match("/\r/", $filearray[0]) AND !preg_match("/\n/", $filearray[0])) {
if (ereg("\r", $filearray[0]) AND !ereg("\n", $filearray[0])) {
return explode("\r", $filearray[0]);
} else {
return $filearray;
+2 -2
View File
@@ -266,7 +266,7 @@ class embedded_cloze_qtype extends default_questiontype {
// The regex will recognize text snippets of type {#X}
// where the X can be any text not containg } or white-space characters.
while (preg_match('/\{#([^[:space:]}]*)}/', $qtextremaining, $regs)) {
while (ereg('\{#([^[:space:]}]*)}', $qtextremaining, $regs)) {
$qtextsplits = explode($regs[0], $qtextremaining, 2);
echo $qtextsplits[0];
echo "<label>"; // MDL-7497
@@ -983,7 +983,7 @@ function qtype_multianswer_extract_question($text) {
$wrapped->feedback[] = '';
}
if (!empty($answerregs[ANSWER_REGEX_ANSWER_TYPE_NUMERICAL])
&& preg_match('/'.NUMERICAL_ALTERNATIVE_REGEX.'/', $altregs[ANSWER_ALTERNATIVE_REGEX_ANSWER], $numregs)) {
&& ereg(NUMERICAL_ALTERNATIVE_REGEX, $altregs[ANSWER_ALTERNATIVE_REGEX_ANSWER], $numregs)) {
$wrapped->answer[] = $numregs[NUMERICAL_CORRECT_ANSWER];
if ($numregs[NUMERICAL_ABS_ERROR_MARGIN]) {
$wrapped->tolerance[] =
+1 -1
View File
@@ -371,7 +371,7 @@ class question_numerical_qtype extends question_shortanswer_qtype {
$rawresponse = str_replace($search, $replace, trim($rawresponse));
// Apply any unit that is present.
if (preg_match('/^([+-]?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)([eE][-+]?[0-9]+)?)([^0-9].*)?$/',
if (ereg('^([+-]?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)([eE][-+]?[0-9]+)?)([^0-9].*)?$',
$rawresponse, $responseparts)) {
if (!empty($responseparts[5])) {
+1 -1
View File
@@ -143,7 +143,7 @@ class user_editadvanced_form extends moodleform {
$err['username'] = get_string('usernamelowercase');
} else {
if (empty($CFG->extendedusernamechars)) {
$string = preg_replace("/[^(-\.[:alnum:])]/i", '', $usernew->username);
$string = eregi_replace("[^(-\.[:alnum:])]", '', $usernew->username);
if ($usernew->username !== $string) {
$err['username'] = get_string('alphanumerical');
}