Commit e5534e6b authored by John C Fiala's avatar John C Fiala
Browse files

bug report #955214 by alex_b,jcfiala:Fixed problem where a url with a...

bug report #955214 by alex_b,jcfiala:Fixed problem where a url with a querystring caused fatal errors.
parent 93b7f6b4
...@@ -415,7 +415,8 @@ function _link_process(&$item, $delta = 0, $field, $entity) { ...@@ -415,7 +415,8 @@ function _link_process(&$item, $delta = 0, $field, $entity) {
$item['attributes'] = serialize($item['attributes']); $item['attributes'] = serialize($item['attributes']);
// Don't save an invalid default value (e.g. 'http://'). // 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($node)) { if ((isset($field['widget']['default_value'][$delta]['url']) && $item['url'] == $field['widget']['default_value'][$delta]['url'])
&& is_object($node)) {
if (!link_validate_url($item['url'])) { if (!link_validate_url($item['url'])) {
unset($item['url']); unset($item['url']);
} }
...@@ -485,11 +486,11 @@ function _link_sanitize(&$item, $delta, &$field, &$node) { ...@@ -485,11 +486,11 @@ function _link_sanitize(&$item, $delta, &$field, &$node) {
} }
// Separate out the query string if any. // Separate out the query string if any.
if (strpos($url, '?') !== FALSE) { if (strpos($url, '?') !== FALSE) {
$item['query'] = substr($url, strpos($url, '?') + 1); $query = substr($url, strpos($url, '?') + 1);
parse_str($query, $query_array);
$item['query'] = $query_array;
$url = substr($url, 0, strpos($url, '?')); $url = substr($url, 0, strpos($url, '?'));
} }
// Save the new URL without the anchor or query.
$item['url'] = $url;
// Create a shortened URL for display. // Create a shortened URL for display.
$display_url = $type == LINK_EMAIL ? str_replace('mailto:', '', $url) : url($url, array('query' => isset($item['query']) ? $item['query'] : NULL, 'fragment' => isset($item['fragment']) ? $item['fragment'] : NULL, 'absolute' => TRUE)); $display_url = $type == LINK_EMAIL ? str_replace('mailto:', '', $url) : url($url, array('query' => isset($item['query']) ? $item['query'] : NULL, 'fragment' => isset($item['fragment']) ? $item['fragment'] : NULL, 'absolute' => TRUE));
...@@ -500,12 +501,13 @@ function _link_sanitize(&$item, $delta, &$field, &$node) { ...@@ -500,12 +501,13 @@ function _link_sanitize(&$item, $delta, &$field, &$node) {
// Use the title defined at the field level. // Use the title defined at the field level.
if ($field['settings']['title'] == 'value' && strlen(trim($field['settings']['title_value']))) { if ($field['settings']['title'] == 'value' && strlen(trim($field['settings']['title_value']))) {
$item['title'] = $field['settings']['title_value']; $title = $field['settings']['title_value'];
} }
// Use the title defined by the user at the widget level. // Use the title defined by the user at the widget level.
else { else if (isset($item['title'])) {
$title = $item['title']; $title = $item['title'];
} }
// Replace tokens. // Replace tokens.
if (module_exists('token') && ($field['title'] == 'value' || $field['enable_tokens'])) { if (module_exists('token') && ($field['title'] == 'value' || $field['enable_tokens'])) {
// Load the node if necessary for nodes in views. // Load the node if necessary for nodes in views.
...@@ -513,7 +515,7 @@ function _link_sanitize(&$item, $delta, &$field, &$node) { ...@@ -513,7 +515,7 @@ function _link_sanitize(&$item, $delta, &$field, &$node) {
$title = filter_xss(token_replace($title, 'node', $token_node), array('b', 'br', 'code', 'em', 'i', 'img', 'span', 'strong', 'sub', 'sup', 'tt', 'u')); $title = filter_xss(token_replace($title, 'node', $token_node), array('b', 'br', 'code', 'em', 'i', 'img', 'span', 'strong', 'sub', 'sup', 'tt', 'u'));
$item['html'] = TRUE; $item['html'] = TRUE;
} }
$item['display_title'] = empty($title) ? $item['display_url'] : $title; $item['title'] = empty($title) ? $item['display_url'] : $title;
if (!isset($item['attributes'])) { if (!isset($item['attributes'])) {
$item['attributes'] = array(); $item['attributes'] = array();
...@@ -550,12 +552,14 @@ function _link_sanitize(&$item, $delta, &$field, &$node) { ...@@ -550,12 +552,14 @@ function _link_sanitize(&$item, $delta, &$field, &$node) {
$item['attributes'] = array_filter($item['attributes']); $item['attributes'] = array_filter($item['attributes']);
// Sets title to trimmed url if one exists // Sets title to trimmed url if one exists
// @TODO: Do we need this? It seems not.
if(!empty($item['display_url']) && empty($item['title'])) { if(!empty($item['display_url']) && empty($item['title'])) {
$item['title'] = $item['display_url']; $item['title'] = $item['display_url'];
} }
elseif(!isset($item['title'])) { elseif(!isset($item['title'])) {
$item['title'] = $item['url']; $item['title'] = $item['url'];
} }
} }
/** /**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment