Update plugin docblocks
Closes #3186651
Merge request reports
Activity
added 1 commit
- 0b31de2d - Reorganize regex to helper class and add default render element key
added 895 commits
-
0b31de2d...f3d81ccd - 891 commits from branch
project:9.2.x
- cdd64da5 - Update plugin docblocks
- f515f606 - Add validation
- 84c12a6b - CS fix
- 70f996ca - Reorganize regex to helper class and add default render element key
Toggle commit list-
0b31de2d...f3d81ccd - 891 commits from branch
66 67 $value = trim($element['#value']); 67 68 $form_state->setValueForElement($element, $value); 68 69 69 if ($value !== '' && !UrlHelper::isValid($value, TRUE)) { 70 $form_state->setError($element, t('The URL %url is not valid.', ['%url' => $value])); 70 if ($value !== '') { 71 if ($element['#require_url'] && !UrlHelper::isValid($value, TRUE)) { 72 $form_state->setError($element, t('The URL %url is not valid.', ['%url' => $value])); 73 } 74 elseif (!UrlHelper::validateUri($value)) { 75 $form_state->setError($element, t('The URI %uri is not valid.', ['%uri' => $value])); 53 54 // - That it is well formed (parse_url() returns FALSE if not). 54 55 // - That it contains a scheme (parse_url(, PHP_URL_SCHEME) returns NULL if 55 56 // not). 56 if ($typed_data instanceof UriInterface && in_array(parse_url($value, PHP_URL_SCHEME), [NULL, FALSE], TRUE)) { 57 if ($typed_data instanceof UriInterface && !UrlHelper::validateUri($value)) { 26 26 return [ 27 27 'size' => 60, 28 28 'placeholder' => '', 29 'require_url' => TRUE, 499 | (?:[A-Za-z0-9\-._~!$&'()*+,;=]|%[0-9A-Fa-f]{2})* 500 ) 501 (?: : [0-9]* )? 502 (?:\/ (?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f]{2})* )* 503 | \/ 504 (?: (?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f]{2})+ 505 (?:\/ (?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f]{2})* )* 506 )? 507 | (?:[A-Za-z0-9\-._~!$&'()*+,;=@] |%[0-9A-Fa-f]{2})+ 508 (?:\/ (?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f]{2})* )* 509 | 510 ) 511 (?:\? (?:[A-Za-z0-9\-._~!$&'()*+,;=:@\/?]|%[0-9A-Fa-f]{2})* )? 512 (?:\# (?:[A-Za-z0-9\-._~!$&'()*+,;=:@\/?]|%[0-9A-Fa-f]{2})* )? 513 )$/x"; 514 return preg_match($regex, $value); This function made me launch out loud.
To be honest, i think we would benifit from a set of unit tests here. This might be a good place to start for some possibilities?
https://github.com/peterpostmann/php-parse_uri/blob/master/tests/parse_uriTest.php
Also, wouldn't we be able to do this with default php functions?
https://www.php.net/manual/en/filter.filters.validate.php this seems to validate URL's against http://www.faqs.org/rfcs/rfc2396.html which is the basic URI spec?
@mstenta is correct. The built-in function does not work as advertised.
I think this would be good. In a way it is really really weird we say URI but dont support URI outside Drupals internal schemes..
Do kinda wonder if this will make some things in other parts of core get a little confusing because vars/comment/methods assume URL, but we might be good there.