diff --git a/web/sites/all/modules/contrib/link/tests/LinkFieldValidateTest.test b/web/sites/all/modules/contrib/link/tests/LinkFieldValidateTest.test --- a/web/sites/all/modules/contrib/link/tests/LinkFieldValidateTest.test (revision fc334357ea90f66bb19039a923c717e1a3121a8d) +++ b/web/sites/all/modules/contrib/link/tests/LinkFieldValidateTest.test (date 1651759971035) @@ -39,23 +39,19 @@ $field_name = $this->createLinkField(); $label = $this->randomName(); - $settings = array( + $edit = array( 'title' => $label, - $field_name => array( - LANGUAGE_NONE => array( - array( - 'title' => $label, - 'url' => $url, - ), - ), - ), + $field_name . '[und][0][title]' => $label, + $field_name . '[und][0][url]' => $url, ); + $this->drupalPost(NULL, $edit, t('Save')); + $this->assertRaw(' has been created.', 'Node created'); - $node = $this->drupalCreateNode($settings); + $nid = 1; //$matches[1]; - $this->assertNotNull($node, ' has been created.', 'Node created'); + $node = node_load($nid); - $this->assertEqual($url, $node->{$field_name}[LANGUAGE_NONE][0]['url']); + $this->assertEqual($url, $node->{$field_name}['und'][0]['url']); } /** @@ -309,13 +305,9 @@ * Validate that an internal url would be accepted. */ public function testLinkInternalUrl() { - // Create the content first. $node = $this->drupalCreateNode(); - $link = 'node/' . $node->nid; $this->linkTestValidateUrl($link); - $type = link_url_type($link); - $this->assertEqual(LINK_INTERNAL, $type, 'Test ' . $link . ' is an internal link.'); } /** diff --git a/web/sites/all/modules/contrib/link/link.module b/web/sites/all/modules/contrib/link/link.module --- a/web/sites/all/modules/contrib/link/link.module (revision fc334357ea90f66bb19039a923c717e1a3121a8d) +++ b/web/sites/all/modules/contrib/link/link.module (date 1651759857364) @@ -370,7 +370,7 @@ */ function link_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) { foreach ($items as $delta => $value) { - _link_process($items[$delta], $delta, $field, $entity, $instance); + _link_process($items[$delta], $delta, $field, $entity); } } @@ -379,7 +379,7 @@ */ function link_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) { foreach ($items as $delta => $value) { - _link_process($items[$delta], $delta, $field, $entity, $instance); + _link_process($items[$delta], $delta, $field, $entity); } } @@ -451,20 +451,9 @@ /** * Prepares the item attributes and url for storage. * - * @param array $item - * Link field values. - * @param array $delta - * The sequence number for current values. - * @param array $field - * The field structure array. - * @param object $entity - * Entity object. - * @param array $instance - * The instance structure for $field on $entity's bundle. - * * @codingStandardsIgnoreStart */ -function _link_process(&$item, $delta, $field, $entity, $instance) { +function _link_process(&$item, $delta, $field, $entity) { // @codingStandardsIgnoreEnd // Trim whitespace from URL. if (!empty($item['url'])) { @@ -546,8 +535,7 @@ // Don't save an invalid default value (e.g. 'http://'). if ((isset($field['widget']['default_value'][$delta]['url']) && $item['url'] == $field['widget']['default_value'][$delta]['url']) && is_object($entity)) { - $langcode = !empty($entity) ? field_language($instance['entity_type'], $entity, $instance['field_name']) : LANGUAGE_NONE; - if (!link_validate_url($item['url'], $langcode)) { + if (!link_validate_url($item['url'])) { unset($item['url']); } } @@ -682,7 +670,7 @@ } } - $type = link_url_type($item['url']); + $type = link_validate_url($item['url']); // If the type of the URL cannot be determined and URL validation is disabled, // then assume LINK_EXTERNAL for later processing. if ($type == FALSE && $instance['settings']['validate_url'] === 0) { @@ -1586,7 +1574,7 @@ watchdog('link', $e->getMessage(), array(), WATCHDOG_ERROR); } $url = trim($url); - $type = link_url_type($url); + $type = link_validate_url($url); if ($type === LINK_EXTERNAL) { // Check if there is no protocol specified. @@ -1622,57 +1610,6 @@ } } -/** - * Validates a URL. - * - * @param string $text - * Url to be validated. - * @param string $langcode - * An optional language code to look up the path in. - * - * @return bool - * True if a valid link, FALSE otherwise. - */ -function link_validate_url($text, $langcode = NULL) { - $text = _link_clean_relative($text); - $text = link_cleanup_url($text); - $type = link_url_type($text); - - if ($type == LINK_EXTERNAL) { - $scheme = parse_url($text, PHP_URL_SCHEME); - if ($scheme && !in_array(strtolower($scheme), array('http', 'https', 'ftp', 'feed'))) { - // valid_url() cannot validate this scheme (which can be anything, if - // filter_allowed_protocols was changed). The exact syntax is likely - // unknown, so skip the next block and accept anything. - $type = $scheme; - } - } - - if ($type && ($type == LINK_INTERNAL || $type == LINK_EXTERNAL)) { - $flag = valid_url($text, $type == LINK_EXTERNAL); - if (!$flag) { - $normal_path = drupal_get_normal_path($text, $langcode); - $parsed_link = parse_url($normal_path, PHP_URL_PATH); - if ($normal_path != $parsed_link) { - $normal_path = $parsed_link; - } - $flag = drupal_valid_path($normal_path); - } - if (!$flag) { - $flag = file_exists($normal_path); - } - if (!$flag) { - $uri = file_build_uri($normal_path); - $flag = file_exists($uri); - } - } - else { - $flag = (bool) $type; - } - - return $flag; -} - /** * Cleaner of relatives urls. * @@ -1699,19 +1636,19 @@ } /** - * Type check a URL. + * Validates a URL. * * Accepts all URLs following RFC 1738 standard for URL formation and all e-mail * addresses following the RFC 2368 standard for mailto address formation. * * @param string $text - * Url to be checked. + * Url to be validated. * * @return mixed * Returns boolean FALSE if the URL is not valid. On success, returns one of * the LINK_(linktype) constants. */ -function link_url_type($text) { +function link_validate_url($text) { // @todo Complete letters. // @codingStandardsIgnoreStart $link_ichars_domain = (string) html_entity_decode(implode("", array( Index: web/sites/all/modules/contrib/link/tests/LinkValidationApiTest.test IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/web/sites/all/modules/contrib/link/tests/LinkValidationApiTest.test b/web/sites/all/modules/contrib/link/tests/LinkValidationApiTest.test --- a/web/sites/all/modules/contrib/link/tests/LinkValidationApiTest.test (revision fc334357ea90f66bb19039a923c717e1a3121a8d) +++ b/web/sites/all/modules/contrib/link/tests/LinkValidationApiTest.test (date 1651759677671) @@ -159,19 +159,17 @@ * Validate Internal Links. */ public function testValidateInternalLinks() { - $tempfile = drupal_tempnam('public://files', 'test'); $links = array( + 'node/5', 'rss.xml', 'foo#bar', - file_uri_target($tempfile), - drupal_realpath($tempfile), + 'files/test.jpg', + '/var/www/test', ); foreach ($links as $link) { - $type = link_url_type($link); - $this->assertEqual(LINK_INTERNAL, $type, 'Test ' . $link . ' is an internal link.'); $valid = link_validate_url($link); - $this->assertTrue($valid, 'Test ' . $link . ' is valid internal link.'); + $this->assertEqual(LINK_INTERNAL, $valid, 'Test ' . $link . ' internal link.'); } } @@ -193,6 +191,7 @@ 'http://255.255.255.255:4823/', 'www.test-site.com', 'http://example.com/index.php?q=node/123', + 'http://example.com/index.php?page=this\that', 'http://example.com/?first_name=Joe Bob&last_name=Smith', // Anchors. 'http://www.example.com/index.php#test', @@ -225,9 +224,8 @@ } } foreach ($links as $link) { - $type = link_url_type($link); - $this->assertEqual(LINK_EXTERNAL, $type, 'Testing that ' . $link . ' is an external link.'); $valid = link_validate_url($link); + $this->assertEqual(LINK_EXTERNAL, $valid, 'Testing that ' . $link . ' is an external link.'); $this->assertTrue($valid, 'Test ' . $link . ' is valid external link.'); // The following two lines are commented out and only used for // comparisons. @@ -253,8 +251,6 @@ 'http://.www.foo.bar./', // Domains can't have sections starting with a dash. // 'http://www.-fudge.com/', - 'http://example.com/index.php?page=this\that', - 'example@example.com', ); foreach ($links as $link) { $valid = link_validate_url($link);