From 5cace3d49657896444f2527d36c8b226351672f5 Mon Sep 17 00:00:00 2001 From: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Tue, 21 Jan 2025 08:25:19 +0000 Subject: [PATCH] Revert codestyle change (str_contains) to continue support for PHP 7.x. --- api/public/cors.php | 6 +++--- classes/library_render.php | 2 +- cli/ast_filter_tester.php | 2 +- cli/maximalibcheck.php | 10 +++++----- corsscripts/cors.php | 6 +++--- doc/docslib.php | 2 +- doc/maintenance.php | 4 ++-- questiontype.php | 2 +- stack/cas/cassession2.class.php | 2 +- stack/cas/castext2/blocks/iframe.block.php | 2 +- stack/cas/castext2/castext2_evaluatable.class.php | 2 +- stack/cas/connector.class.php | 8 ++++---- stack/cas/connectorhelper.class.php | 2 +- stack/cas/keyval.class.php | 2 +- .../parsingrules/201_sig_figs_validation.filter.php | 2 +- .../202_decimal_places_validation.filter.php | 2 +- stack/cas/parsingrules/450_split_floats.filter.php | 8 ++++---- .../parsingrules/801_singleton_numeric.filter.php | 6 +++--- .../cas/parsingrules/802_singleton_units.filter.php | 2 +- .../910_inert_float_for_display.filter.php | 2 +- stack/input/dropdown/dropdown.class.php | 2 +- stack/maximaparser/corrective_parser.php | 12 ++++++------ stack/prt.evaluatable.class.php | 2 +- stack/questionreport.class.php | 6 +++--- stack/utils.class.php | 6 +++--- tests/cassession2_test.php | 2 +- tests/fixtures/test_base.php | 4 ++-- vle_specific.php | 2 +- 28 files changed, 55 insertions(+), 55 deletions(-) diff --git a/api/public/cors.php b/api/public/cors.php index 35fc6faad..1cd68d2cf 100644 --- a/api/public/cors.php +++ b/api/public/cors.php @@ -27,9 +27,9 @@ if (isset($_GET['question'])) { $is_question = false; } -if (str_contains($scriptname, '..') - || str_contains($scriptname, '/') - || str_contains($scriptname, '\\')) { +if (str_pos($scriptname, '..') !== false + || strpos($scriptname, '/') !== false + || strpos($scriptname, '\\') !== false) { die("No such script here."); } diff --git a/classes/library_render.php b/classes/library_render.php index 9c39b56b9..1ed5fe0a9 100644 --- a/classes/library_render.php +++ b/classes/library_render.php @@ -136,7 +136,7 @@ class library_render extends \external_api { } catch (\stack_exception $e) { // If the question is not a STACK question we can't render it // but we still want users to be able to import it. - if (str_contains($e->getMessage(), 'not of type STACK')) { + if (strpos($e->getMessage(), 'not of type STACK') !== false) { $xmldata = new SimpleXMLElement($qcontents); $questiontext = (string) $xmldata->question->questiontext->text; $questionname = (string) $xmldata->question->name->text; diff --git a/cli/ast_filter_tester.php b/cli/ast_filter_tester.php index de1234fca..69eb9425e 100644 --- a/cli/ast_filter_tester.php +++ b/cli/ast_filter_tester.php @@ -133,7 +133,7 @@ $filters = stack_parsing_rule_factory::list_filters(); if ($only !== false) { $f = []; foreach ($filters as $filter) { - if (str_contains($filter, $only)) { + if (strpos($filter, $only) !== false) { $f[] = $filter; } } diff --git a/cli/maximalibcheck.php b/cli/maximalibcheck.php index ce8b1ddac..11abc8616 100644 --- a/cli/maximalibcheck.php +++ b/cli/maximalibcheck.php @@ -35,10 +35,10 @@ $globalvariablesused = []; // Get the files ../stack/maxima/*.mac. foreach (glob("../stack/maxima/*.mac") as $filename) { - if (str_contains($filename, 'rtest_')) { + if (strpos($filename, 'rtest_') !== false) { continue; } - if (str_contains($filename, 'unittests_load.mac')) { + if (strpos($filename, 'unittests_load.mac') !== false) { continue; } @@ -62,7 +62,7 @@ foreach (glob("../stack/maxima/*.mac") as $filename) { } } - if (str_contains($filename, 'assessment.mac')) { + if (strpos($filename, 'assessment.mac') !== false) { // Some parser breaking cases. List calling and the wacky syntax of defines. $contents = str_replace('?\*autoconf\-version\*', '"cencored"', $contents); $contents = str_replace('define(UNARY_RECIP a, a^(-1)),', '"cencored",', $contents); @@ -76,12 +76,12 @@ foreach (glob("../stack/maxima/*.mac") as $filename) { $contents = str_replace('ret:ev(exc1 %or exc2, simp)', 'ret:ev(exc1 or exc2, simp)', $contents); } - if (str_contains($filename, 'stackmaxima.mac')) { + if (strpos($filename, 'stackmaxima.mac') !== false) { // Some parser breaking cases. $contents = str_replace('?\*autoconf\-version\*', '"cencored"', $contents); } - if (str_contains($filename, 'intervals.mac')) { + if (strpos($filename, 'intervals.mac') !== false) { // Some parser breaking cases. $contents = str_replace('stack_single_variable_solver_rec(ex %and (v>=0), v)', 'stack_single_variable_solver_rec(ex and (v>=0), v)', $contents); diff --git a/corsscripts/cors.php b/corsscripts/cors.php index ed11d73cd..74a86e0c9 100644 --- a/corsscripts/cors.php +++ b/corsscripts/cors.php @@ -22,9 +22,9 @@ $scriptname = urldecode($_GET['name']); -if (str_contains($scriptname, '..') - || str_contains($scriptname, '/') - || str_contains($scriptname, '\\')) { +if (strpos($scriptname, '..') !== false + || strpos($scriptname, '/') !== false + || strpos($scriptname, '\\') !== false) { die("No such script here."); } diff --git a/doc/docslib.php b/doc/docslib.php index 676964f13..bc002b3a4 100644 --- a/doc/docslib.php +++ b/doc/docslib.php @@ -136,7 +136,7 @@ function stack_docs_no_found($links) { function stack_docs_page($links, $file) { $preprocess = true; // This auto-generated file does not need maths processing. - if (str_contains($file, 'Answer_Tests/Results')) { + if (strpos($file, 'Answer_Tests/Results') !== false) { $preprocess = false; } $body = ''; diff --git a/doc/maintenance.php b/doc/maintenance.php index e5c72f639..8e8065da6 100644 --- a/doc/maintenance.php +++ b/doc/maintenance.php @@ -120,12 +120,12 @@ function report($d) { $link = implode('/', $segs); // Finally it looks like #--- are getting parsed in the request, let's omit them. - if (str_contains($link, '#')) { + if (strpos($link, '#') !== false) { $link = substr($link, 0, strpos($link, '#')); } } $hs = get_headers($link); - if (str_contains($hs[0], '404')) { + if (strpos($hs[0], '404') !== false) { $a[] = [$fpath, 'E', 'Error 404 [' . $found[1][$i] . '] appears to be a dead link.']; } else { $fileslinkedto[$found[0][$i]] = true; diff --git a/questiontype.php b/questiontype.php index c1456e2d7..c309f9a00 100644 --- a/questiontype.php +++ b/questiontype.php @@ -1926,7 +1926,7 @@ class qtype_stack extends question_type { * @return array updated $errors array. */ protected function validate_cas_text($errors, $value, $fieldname, $fixingdollars, $session = null) { - if (!$fixingdollars && str_contains($value, '$$')) { + if (!$fixingdollars && strpos($value, '$$') !== false) { $errors[$fieldname][] = stack_string('forbiddendoubledollars'); } diff --git a/stack/cas/cassession2.class.php b/stack/cas/cassession2.class.php index 2b4ef77c1..5805b8968 100644 --- a/stack/cas/cassession2.class.php +++ b/stack/cas/cassession2.class.php @@ -454,7 +454,7 @@ class stack_cas_session2 { $last = null; $errb = []; foreach ($err as $error) { - if (str_contains($error->get_legacy_error(), 'STACK: ignore previous error.')) { + if (strpos($error->get_legacy_error(), 'STACK: ignore previous error.') !== false) { $last = null; } else { if ($last !== null) { diff --git a/stack/cas/castext2/blocks/iframe.block.php b/stack/cas/castext2/blocks/iframe.block.php index fe9e929ba..d9b206f45 100644 --- a/stack/cas/castext2/blocks/iframe.block.php +++ b/stack/cas/castext2/blocks/iframe.block.php @@ -151,7 +151,7 @@ class stack_cas_castext2_iframe extends stack_cas_castext2_block { $title = $parameters['title']; // Counter updates. foreach (self::$counters as $key => $value) { - if (str_contains($title, $key)) { + if (strpos($title, $key) !== false) { $title = str_replace($key, '' . $value, $title); self::$counters[$key] = $value + 1; } diff --git a/stack/cas/castext2/castext2_evaluatable.class.php b/stack/cas/castext2/castext2_evaluatable.class.php index 4a76a624c..14ebc52b0 100644 --- a/stack/cas/castext2/castext2_evaluatable.class.php +++ b/stack/cas/castext2/castext2_evaluatable.class.php @@ -173,7 +173,7 @@ class castext2_evaluatable implements cas_raw_value_extractor { } if ($this->valid) { - if ($this->context === '/qt' || str_contains($this->context, 'scenetext') || + if ($this->context === '/qt' || strpos($this->context, 'scenetext') !== false || $this->context === 'validation-questiontext') { $options['in main content'] = true; } diff --git a/stack/cas/connector.class.php b/stack/cas/connector.class.php index f12a89197..0ddc28450 100644 --- a/stack/cas/connector.class.php +++ b/stack/cas/connector.class.php @@ -190,7 +190,7 @@ abstract class stack_cas_connection_base implements stack_cas_connection { $this->timeout = $settings->castimeout; $this->serveruserpass = $settings->serveruserpass; $this->debug = $debuglog; - if (str_contains($CFG->wwwroot, '_')) { + if (strpos($CFG->wwwroot, '_') !== false) { $this->wwwroothasunderscores = true; $this->wwwrootfixupfind = str_replace('_', '\_', $CFG->wwwroot); $this->wwwrootfixupreplace = $CFG->wwwroot; @@ -334,15 +334,15 @@ abstract class stack_cas_connection_base implements stack_cas_connection { $errorclean = []; foreach ($error as $err) { // This case arises when we use a numerical test for algebraic equivalence. - if (str_contains($err, 'STACK: ignore previous error.')) { + if (strpos($err, 'STACK: ignore previous error.') !== false) { $err = ''; } - if (str_contains($err, '0 to a negative exponent')) { + if (strpos($err, '0 to a negative exponent') !== false) { $err = stack_string('Maxima_DivisionZero'); } - if (str_contains($err, 'args: argument must be a non-atomic expression;')) { + if (strpos($err, 'args: argument must be a non-atomic expression;') !== false) { $err = stack_string('Maxima_Args'); } diff --git a/stack/cas/connectorhelper.class.php b/stack/cas/connectorhelper.class.php index 796ac4eaf..57d2030ea 100644 --- a/stack/cas/connectorhelper.class.php +++ b/stack/cas/connectorhelper.class.php @@ -374,7 +374,7 @@ abstract class stack_connection_helper { } } - if (str_contains($debug, 'failed to load')) { + if (strpos($debug, 'failed to load') !== false) { $message[] = stack_string('settingmaximalibraries_failed'); $success = false; } diff --git a/stack/cas/keyval.class.php b/stack/cas/keyval.class.php index 7375538b6..37050bb6f 100644 --- a/stack/cas/keyval.class.php +++ b/stack/cas/keyval.class.php @@ -109,7 +109,7 @@ class stack_cas_keyval { $str = str_replace('?', 'QMCHAR', $str); // CAS keyval may not contain @ outside strings. - if (str_contains($str, '@')) { + if (strpos($str, '@') !== false { $this->errors[] = new $this->errclass(stack_string('illegalcaschars'), $this->context); $this->valid = false; return false; diff --git a/stack/cas/parsingrules/201_sig_figs_validation.filter.php b/stack/cas/parsingrules/201_sig_figs_validation.filter.php index f70a5c970..694fb172e 100644 --- a/stack/cas/parsingrules/201_sig_figs_validation.filter.php +++ b/stack/cas/parsingrules/201_sig_figs_validation.filter.php @@ -63,7 +63,7 @@ class stack_ast_filter_201_sig_figs_validation implements stack_cas_astfilter_pa $pre = explode('.', $raw)[0]; $post = ''; - if (str_contains($raw, '.')) { + if (strpos($raw, '.') !== false) { $post = explode('.', $raw)[1]; } $min = null; diff --git a/stack/cas/parsingrules/202_decimal_places_validation.filter.php b/stack/cas/parsingrules/202_decimal_places_validation.filter.php index 7db8adb9d..c243e6a0a 100644 --- a/stack/cas/parsingrules/202_decimal_places_validation.filter.php +++ b/stack/cas/parsingrules/202_decimal_places_validation.filter.php @@ -60,7 +60,7 @@ class stack_ast_filter_202_decimal_places_validation implements stack_cas_astfil $raw = explode('e', $raw)[0]; $post = ''; - if (str_contains($raw, '.')) { + if (strpos($raw, '.') !== false) { $post = explode('.', $raw)[1]; } if ($this->min !== null && $this->min > 0) { diff --git a/stack/cas/parsingrules/450_split_floats.filter.php b/stack/cas/parsingrules/450_split_floats.filter.php index ed4430d1e..1136aa73b 100644 --- a/stack/cas/parsingrules/450_split_floats.filter.php +++ b/stack/cas/parsingrules/450_split_floats.filter.php @@ -31,9 +31,9 @@ class stack_ast_filter_450_split_floats implements stack_cas_astfilter_exclusion $process = function($node) use (&$answernotes) { if ($node instanceof MP_Float && $node->raw !== null) { $replacement = false; - if (str_contains($node->raw, 'e')) { + if (strpos($node->raw, 'e') !== false) { $parts = explode('e', $node->raw); - if (str_contains($parts[0], '.')) { + if (strpos($parts[0], '.') !== false) { $replacement = new MP_Operation('*', new MP_Float(floatval($parts[0]), $parts[0]), new MP_Operation('*', new MP_Identifier('e'), new MP_Integer(intval($parts[1])))); } else { @@ -49,9 +49,9 @@ class stack_ast_filter_450_split_floats implements stack_cas_astfilter_exclusion new MP_Identifier('e')), new MP_Integer($val)); $replacement->lhs->position['insertstars'] = true; } - } else if (str_contains($node->raw, 'E')) { + } else if (strpos($node->raw, 'E') !== false) { $parts = explode('E', $node->raw); - if (str_contains($parts[0], '.')) { + if (strpos($parts[0], '.') !== false) { $replacement = new MP_Operation('*', new MP_Float(floatval($parts[0]), $parts[0]), new MP_Operation('*', new MP_Identifier('E'), new MP_Integer(intval($parts[1])))); } else { diff --git a/stack/cas/parsingrules/801_singleton_numeric.filter.php b/stack/cas/parsingrules/801_singleton_numeric.filter.php index 7f169279f..8fa4502e8 100644 --- a/stack/cas/parsingrules/801_singleton_numeric.filter.php +++ b/stack/cas/parsingrules/801_singleton_numeric.filter.php @@ -73,7 +73,7 @@ class stack_ast_filter_801_singleton_numeric implements stack_cas_astfilter_para if ($this->float) { // Turn floats that are to small or large to powers of ten. $p = 0; - if (str_contains($node->toString(), 'E')) { + if (strpos($node->toString(), 'E') !== false) { $p = intval(explode('E', $node->toString())[1]); } @@ -279,12 +279,12 @@ class stack_ast_filter_801_singleton_numeric implements stack_cas_astfilter_para public function float_to_power(MP_Float $float): MP_Node { $raw = strtolower($float->raw); $p = 0; - if (str_contains($raw, 'e')) { + if (strpos($raw, 'e') !== false) { $parts = explode('e', $raw); $raw = $parts[0]; $p = intval($parts[1]); } - if (str_contains($raw, '.')) { + if (strpos($raw, '.') !== false) { $parts = explode('.', $raw); $raw = $parts[0] . $parts[1]; $p = $p - strlen($parts[1]); diff --git a/stack/cas/parsingrules/802_singleton_units.filter.php b/stack/cas/parsingrules/802_singleton_units.filter.php index a7467ad02..27d0d1138 100644 --- a/stack/cas/parsingrules/802_singleton_units.filter.php +++ b/stack/cas/parsingrules/802_singleton_units.filter.php @@ -201,7 +201,7 @@ class stack_ast_filter_802_singleton_units implements stack_cas_astfilter_parame // Check floats and fix if need be. foreach ($floats as $node) { - if ((str_contains($node->toString(), 'E') || $this->floattopower) && $node->raw !== null) { + if ((strpos($node->toString(), 'E') !== false || $this->floattopower) && $node->raw !== null) { $p = 0; $parts = explode('E', $node->toString()); $p = intval($parts[1]); diff --git a/stack/cas/parsingrules/910_inert_float_for_display.filter.php b/stack/cas/parsingrules/910_inert_float_for_display.filter.php index 29a1169b2..b6413e654 100644 --- a/stack/cas/parsingrules/910_inert_float_for_display.filter.php +++ b/stack/cas/parsingrules/910_inert_float_for_display.filter.php @@ -47,7 +47,7 @@ class stack_ast_filter_910_inert_float_for_display implements stack_cas_astfilte return true; } $dp = 0; - if (str_contains($raw, '.')) { + if (strpos($raw, '.') !== false) { $parts = explode('.', $raw); $dp = strlen(explode('e', $parts[1])[0]); } diff --git a/stack/input/dropdown/dropdown.class.php b/stack/input/dropdown/dropdown.class.php index df5bd5caa..6c33c26ce 100644 --- a/stack/input/dropdown/dropdown.class.php +++ b/stack/input/dropdown/dropdown.class.php @@ -176,7 +176,7 @@ class stack_dropdown_input extends stack_input { if (is_array($value)) { // Inject strings back if they exist. foreach ($value as $key => $something) { - if (str_contains($something, '[STR:')) { + if (strpos($something, '[STR:') !== false) { foreach ($strings as $skey => $string) { $value[$key] = str_replace("[STR:$skey]", '"' . $string . '"', $value[$key]); } diff --git a/stack/maximaparser/corrective_parser.php b/stack/maximaparser/corrective_parser.php index c79d6c7df..8865e46d4 100644 --- a/stack/maximaparser/corrective_parser.php +++ b/stack/maximaparser/corrective_parser.php @@ -79,9 +79,9 @@ class maxima_corrective_parser { $stringles = str_replace(array_keys($letters), array_values($letters), $stringles); // Check for all three of . and , and ; which must indicate inconsistency. - if (str_contains($stringles, '.') && - str_contains($stringles, ',') && - str_contains($stringles, ';')) { + if (strpos($stringles, '.') !== false && + strpos($stringles, ',') !== false && + strpos($stringles, ';') !== false) { $errors[] = stack_string('stackCas_decimal_usedthreesep'); } $decimals = '.'; @@ -90,7 +90,7 @@ class maxima_corrective_parser { } if ($decimals == ',') { // Clearly there is a lot more work to do here to get this all to work! - if (str_contains($stringles, '.')) { + if (strpos($stringles, '.') !== false) { $answernote[] = 'forbiddenCharDecimal'; $errors[] = stack_string('stackCas_decimal_usedcomma'); return null; @@ -188,7 +188,7 @@ class maxima_corrective_parser { $stringles = trim($stringles); $stringles = preg_replace('!\s+!', ' ', $stringles); - if (str_contains($stringles, ' ')) { + if (strpos($stringles, ' ') !== false) { // Special cases: allow students to type in expressions such as "x>1 and x<4". foreach ($safespacepatterns as $key => $pat) { $stringles = str_replace($key, $pat, $stringles); @@ -449,7 +449,7 @@ class maxima_corrective_parser { $cmds = str_replace('@@Is@@', '[[syntaxexamplehighlight]_[syntaxexamplehighlight]]', $cmds); $answernote[] = 'spaces'; $errors[] = stack_string('stackCas_spaces', ['expr' => stack_maxima_format_casstring($cmds)]); - } else if ($foundchar === ':' && (str_contains($string, ':lisp'))) { + } else if ($foundchar === ':' && (strpos($string, ':lisp') !== false)) { $errors[] = stack_string('stackCas_forbiddenWord', ['forbid' => stack_maxima_format_casstring('lisp')]); $answernote[] = 'forbiddenWord'; diff --git a/stack/prt.evaluatable.class.php b/stack/prt.evaluatable.class.php index 37152a5c6..3c4a077f0 100644 --- a/stack/prt.evaluatable.class.php +++ b/stack/prt.evaluatable.class.php @@ -271,7 +271,7 @@ class prt_evaluatable implements cas_raw_value_extractor { public function get_fverrors($format='strings') { $err = []; foreach ($this->errors as $er) { - if (str_contains($er->get_context(), '/fv')) { + if (strpos($er->get_context(), '/fv') !== false) { if ($format === 'strings') { $err[] = $er->get_legacy_error(); } else { diff --git a/stack/questionreport.class.php b/stack/questionreport.class.php index 2e52f26f1..f762fbf8f 100644 --- a/stack/questionreport.class.php +++ b/stack/questionreport.class.php @@ -292,13 +292,13 @@ class stack_question_report { // Tidy up inputs by (i) trimming status and whitespace, and (2) removing input name. $datas = trim(substr($data, strlen($input . ':'))); $status = 'other'; - if (str_contains($datas, '[score]')) { + if (strpos($datas, '[score]') !== false) { $status = 'score'; $datas = trim(substr($datas, 0, -7)); - } else if (str_contains($datas, '[valid]')) { + } else if (strpos($datas, '[valid]') !== false) { $status = 'valid'; $datas = trim(substr($datas, 0, -7)); - } else if (str_contains($datas, '[invalid]')) { + } else if (strpos($datas, '[invalid]') !== false) { $status = 'invalid'; $datas = trim(substr($datas, 0, -9)); } diff --git a/stack/utils.class.php b/stack/utils.class.php index 53f162ccd..906293b0e 100644 --- a/stack/utils.class.php +++ b/stack/utils.class.php @@ -181,7 +181,7 @@ class stack_utils { $length = strlen($string); for ($i = 0; $i < $length; $i++) { $char = $string[$i]; - if (str_contains($lefts, $char)) { + if (strpos($lefts, $char) !== false) { array_push($openstack, $char); } else if (($closerpos = strpos($rights, $char)) !== false) { @@ -828,9 +828,9 @@ class stack_utils { */ public static function maxima_translate_string(string $string) { $fixed = $string; - if (str_contains($string, '0 to a negative exponent')) { + if (strpos($string, '0 to a negative exponent') !== false) { $fixed = stack_string('Maxima_DivisionZero'); - } else if (str_contains($string, 'args: argument must be a non-atomic expression;')) { + } else if (strpos($string, 'args: argument must be a non-atomic expression;') !== false) { $fixed = stack_string('Maxima_Args'); } return $fixed; diff --git a/tests/cassession2_test.php b/tests/cassession2_test.php index 1cec9631b..0481d095c 100644 --- a/tests/cassession2_test.php +++ b/tests/cassession2_test.php @@ -2190,7 +2190,7 @@ class cassession2_test extends qtype_stack_testcase { $at1->instantiate(); $actual = $s1[0]->get_dispvalue(); - if (str_contains($actual, 'quantile_gamma(')) { + if (strpos($actual, 'quantile_gamma(') !== false) { // Seems that the distrib package is not available. Skip this test. $this->markTestSkipped('Skipping because it seems the distrib package is not installed.'); } diff --git a/tests/fixtures/test_base.php b/tests/fixtures/test_base.php index c4b3a9524..2c64d0056 100644 --- a/tests/fixtures/test_base.php +++ b/tests/fixtures/test_base.php @@ -180,7 +180,7 @@ abstract class qtype_stack_testcase extends advanced_testcase { function(array $matches): string { $decimals = strlen(explode('.', $matches[1])[1] ?? '') ?: 0; $fixedbase = sprintf("%.{$decimals}E", (float)$matches[0]); - return str_contains($matches[2], '+') ? $fixedbase : str_replace('+', '', $fixedbase); + return strpos($matches[2], '+') !== false ? $fixedbase : str_replace('+', '', $fixedbase); }, $content ); @@ -317,7 +317,7 @@ abstract class qtype_stack_walkthrough_test_base extends \qbehaviour_walkthrough $question = $this->quba->get_question($this->slot); $attempt = $this->quba->get_question_attempt($this->slot); $qs = $attempt->get_last_step(); - $this->assertTrue(str_contains($qs->get_new_response_summary(), $note)); + $this->assertTrue(strpos($qs->get_new_response_summary(), $note) !== false); } protected function check_output_contains_text_input($name, $value = null, $enabled = true) { diff --git a/vle_specific.php b/vle_specific.php index 311fcbcb0..54e22ea67 100644 --- a/vle_specific.php +++ b/vle_specific.php @@ -277,7 +277,7 @@ function stack_fetch_included_content(string $url) { if (strpos($lc, 'http://') === 0 || strpos($lc, 'https://') === 0) { $good = true; } else { - if (str_contains($path, '..') || strpos($path, '/') === 0 || strpos($path, '~') === 0) { + if (strpos($path, '..') !== false || strpos($path, '/') === 0 || strpos($path, '~') === 0) { $error = 'Traversing the directory tree is forbidden.'; $good = false; return false; -- GitLab