Commit ca009175 authored by Robert Lyon's avatar Robert Lyon
Browse files

Add validation error for non url input (Bug #1381807)



Change-Id: I743d481c7775079c807e4e93b4bba4d39ceeb61d
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 7ea93380
......@@ -21,6 +21,7 @@ $string['width'] = 'Width';
$string['height'] = 'Height';
$string['widthheightdescription'] = 'Width and height fields are only used for URLs. If you have entered embed or iframe code above, you need to update the width and height within the code itself.';
$string['invalidurl'] = 'Invalid URL';
$string['invalidurlorembed'] = 'Invalid URL or embed code';
//Supported sites language strings
$string['googlevideo'] = 'Google Video';
......
......@@ -214,8 +214,11 @@ class PluginBlocktypeExternalvideo extends SystemBlocktype {
$content = trim($values['videoid']);
if (!filter_var($content, FILTER_VALIDATE_URL)) {
// Not a valid url, so assume it's embed code, and let it go through
// to htmlpurifier.
// Not a valid url, so assume it's embed code so check that it's within a tag
if (!preg_match('/^\<.*\>$/', $content)) {
$form->set_error('videoid', get_string('invalidurlorembed', 'blocktype.externalvideo'), false);
}
// And if so let it go through to htmlpurifier.
return;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment