Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

… sorry
  • Loading branch information...
commit 59fa78efa41f2b1bd9496026bf51d4fc0efadd98 1 parent 199be88
@skodak skodak authored
View
4 calendar/lib.php
@@ -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);
View
4 lib/excel/Worksheet.php
@@ -1264,10 +1264,10 @@ function write_formula($row, $col, $formula, $format = 0)
}
// 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 {
View
26 lib/weblib.php
@@ -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);
}
View
2  question/format/blackboard_6/format.php
@@ -180,7 +180,7 @@ function readdata($filename) {
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;
View
4 question/type/multianswer/questiontype.php
@@ -266,7 +266,7 @@ function print_question_formulation_and_controls(&$question, &$state, $cmoptions
// 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[] =
View
2  question/type/numerical/questiontype.php
@@ -371,7 +371,7 @@ function apply_unit($rawresponse, $units) {
$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])) {
View
2  user/editadvanced_form.php
@@ -143,7 +143,7 @@ function validation($usernew, $files) {
$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');
}
Please sign in to comment.
Something went wrong with that request. Please try again.