Skip to content
Snippets Groups Projects

Update plugin docblocks

Open Brad Jones requested to merge issue/drupal-3186651:3186651-drupal-treats-uris into 9.2.x
4 unresolved threads

Closes #3186651

Merge request reports

Ready to merge by members who can write to the target branch.
  • 1 commit will be added to 9.2.x.
  • Source branch will not be deleted.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
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]));
  • Björn Brala
  • 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)) {
  • Björn Brala
  • 26 26 return [
    27 27 'size' => 60,
    28 28 'placeholder' => '',
    29 'require_url' => TRUE,
    • This probably means we need an update hook of some sort.

    • I don't think an update hook is necessary because the element's require_url setting will default to TRUE if it omitted. So existing behavior will be maintained. If someone wants to allow full URIs (not just URLs), they can set it to FALSE.

    • Please register or sign in to reply
  • Björn Brala
  • 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);
  • 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.

  • Please register or sign in to reply
    Loading