Skip to content

Commit

Permalink
Merge branch 'MDL-65412-master' of http://github.com/dravek/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Apr 25, 2019
2 parents b63c0b9 + baf5551 commit 47fde84
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions customfield/field/text/classes/field_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,16 @@ public function config_form_validation(array $data, $files = array()) : array {
$errors['configdata[displaysize]'] = get_string('errorconfigdisplaysize', 'customfield_text');
}

$link = $data['configdata']['link'];
if (strlen($link)) {
require_once($CFG->dirroot . '/lib/validateurlsyntax.php');
if (strpos($link, '$$') === false) {
$errors['configdata[link]'] = get_string('errorconfiglinkplaceholder', 'customfield_text');
} else if (!validateUrlSyntax(str_replace('$$', 'XYZ', $link), 's+H?S?F-E-u-P-a?I?p?f?q?r?')) {
// This validation is more strict than PARAM_URL - it requires the protocol and it must be either http or https.
$errors['configdata[link]'] = get_string('errorconfigdisplaysize', 'customfield_text');
if (isset($data['configdata']['link'])) {
$link = $data['configdata']['link'];
if (strlen($link)) {
require_once($CFG->dirroot . '/lib/validateurlsyntax.php');
if (strpos($link, '$$') === false) {
$errors['configdata[link]'] = get_string('errorconfiglinkplaceholder', 'customfield_text');
} else if (!validateUrlSyntax(str_replace('$$', 'XYZ', $link), 's+H?S?F-E-u-P-a?I?p?f?q?r?')) {
// This validation is more strict than PARAM_URL - it requires the protocol and it must be either http or https.
$errors['configdata[link]'] = get_string('errorconfigdisplaysize', 'customfield_text');
}
}
}

Expand Down

0 comments on commit 47fde84

Please sign in to comment.