N°4515 Fix default validation pattern for AttributeURL (#249)

URL containing ":" in their path were rejected. This caused problems with some URL from Alfresco or Sharepoint...
The default regexp used by AttributeURL was updated to avoid this.
Warning, check your config to see if you have any custom regexp configured (`url_validation_pattern` config parameter) !

Also a test was added to document the default regexp.
This commit is contained in:
Pierre Goiffon
2021-12-29 11:43:07 +01:00
committed by GitHub
parent ed12f98075
commit ffd0bbb1a4
4 changed files with 72 additions and 4 deletions

View File

@@ -854,10 +854,12 @@ class Config
'url_validation_pattern' => [
'type' => 'string',
'description' => 'Regular expression to validate/detect the format of an URL (URL attributes and Wiki formatting for Text attributes)',
'default' => '(https?|ftp)\://([a-zA-Z0-9+!*(),;?&=\$_.-]+(\:[a-zA-Z0-9+!*(),;?&=\$_.-]+)?@)?([a-zA-Z0-9-.]{3,})(\:[0-9]{2,5})?(/([a-zA-Z0-9%+\$_-]\.?)+)*/?(\?[a-zA-Z+&\$_.-][a-zA-Z0-9;:[\]@&%=+/\$_.-]*)?(#[a-zA-Z_.-][a-zA-Z0-9+\$_.-]*)?',
// SHEME.......... USER....................... PASSWORD.......................... HOST/IP........... PORT.......... PATH........................ GET............................................ ANCHOR............................
'default' => /** @lang RegExp */
'(https?|ftp)\://([a-zA-Z0-9+!*(),;?&=\$_.-]+(\:[a-zA-Z0-9+!*(),;?&=\$_.-]+)?@)?([a-zA-Z0-9-.]{3,})(\:[0-9]{2,5})?(/([a-zA-Z0-9:%+\$_-]\.?)+)*/?(\?[a-zA-Z+&\$_.-][a-zA-Z0-9;:[\]@&%=+/\$_.-]*)?(#[a-zA-Z_.-][a-zA-Z0-9+\$_.-]*)?',
// SCHEME....... USER....................... PASSWORD.......................... HOST/IP........... PORT.......... PATH......................... GET............................................ ANCHOR..........................
// Example: http://User:passWord@127.0.0.1:8888/patH/Page.php?arrayArgument[2]=something:blah20#myAnchor
// Origin of this regexp: http://www.php.net/manual/fr/function.preg-match.php#93824
// RegExp source: http://www.php.net/manual/fr/function.preg-match.php#93824
// Update with N°4515
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => true,
@@ -1600,6 +1602,16 @@ class Config
return $this->m_aSettings[$sPropCode]['value'];
}
/**
* @param string $sPropCode
*
* @return mixed
*/
public function GetDefault($sPropCode)
{
return $this->m_aSettings[$sPropCode]['default'];
}
/**
* Whether the $sPropCode parameter has a custom value or the default one.
*