diff --git a/core/config.class.inc.php b/core/config.class.inc.php index 280472e02..28d486731 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -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. * diff --git a/test/core/AttributeDefTest.inc.php b/test/core/AttributeDefTest.inc.php index d2b4b3f7a..1ff8168d8 100644 --- a/test/core/AttributeDefTest.inc.php +++ b/test/core/AttributeDefTest.inc.php @@ -29,5 +29,4 @@ class AttributeDefTest extends ItopDataTestCase { $this->assertEquals(["status" => "ENUM('active','inactive') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"], $aImportColumns); } - } \ No newline at end of file diff --git a/test/core/AttributeURLDefaultPattern.php b/test/core/AttributeURLDefaultPattern.php new file mode 100644 index 000000000..bf647db2d --- /dev/null +++ b/test/core/AttributeURLDefaultPattern.php @@ -0,0 +1,14 @@ +GetDefault('url_validation_pattern'); + } +} diff --git a/test/core/AttributeURLTest.php b/test/core/AttributeURLTest.php new file mode 100644 index 000000000..9d75fcbb0 --- /dev/null +++ b/test/core/AttributeURLTest.php @@ -0,0 +1,43 @@ +'_blank', "allowed_values"=>null, "sql"=>'url', "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array(), "always_load_in_tables"=>false]); + $bResult = $oAttDefUrl->CheckFormat($sUrlValue); + + $this->assertSame($iExpectedResult, $bResult); + } + + public function CheckFormatProvider(): array + { + return [ + 'Simple https URL' => ['https://www.combodo.com/itop', 1], + 'Simple FTP URL' => ['ftp://user:password@myftp.mydomain.com', 1], + 'Sharepoint URL 1' => ['https://mydomain1.sharepoint.com/:i:/r/sites/DSIMyDept/Shared%20Documents/Architecture%20Technique/02%20-%20R%C3%A9seau/Baie%2025C/Baie%201er/Baie-25C-1er.jpg?csf=1&web=1&e=Il3txR', 1], + 'Sharepoint URL 2' => ['https://mydomain2.sharepoint.com/:u:/r/sites/DIS/ITSM/00_Admin_iTOP/iTop%20-%20Upgrade%20manuel/Procedure%20upgrade%20Combodo.url?csf=1&web=1&e=DAF0i3', 1], + 'Alfresco URL 2' => ['http://alfresco.mydomain3.org/share/page/site/books/document-details?nodeRef=workspace://SpacesStore/6274f55f-a25b-4762-a863-77f7066f2034', 1], + ]; + } +}