Merge pull request #13817 from nijel/link-or-button
Simplify handling of long URLs in Util::linkOrButton
This commit is contained in:
commit
152c4857c2
@ -276,6 +276,9 @@ var AJAX = {
|
||||
var params = 'ajax_request=true&ajax_page_request=true';
|
||||
if (! isLink) {
|
||||
params += '&' + $(this).serialize();
|
||||
} else if (AJAX.source.attr('data-post')) {
|
||||
params += '&' + AJAX.source.attr('data-post');
|
||||
isLink = false;
|
||||
}
|
||||
if (! (history && history.pushState)) {
|
||||
// Add a list of menu hashes that we have in the cache to the request
|
||||
|
||||
@ -665,18 +665,7 @@ function confirmLink (theLink, theSqlQuery) {
|
||||
|
||||
var is_confirmed = confirm(PMA_sprintf(PMA_messages.strDoYouReally, theSqlQuery));
|
||||
if (is_confirmed) {
|
||||
if ($(theLink).hasClass('formLinkSubmit')) {
|
||||
var name = 'is_js_confirmed';
|
||||
|
||||
if ($(theLink).attr('href').indexOf('usesubform') !== -1) {
|
||||
var matches = $(theLink).attr('href').substr('#').match(/usesubform\[(\d+)\]/i);
|
||||
if (matches !== null) {
|
||||
name = 'subform[' + matches[1] + '][is_js_confirmed]';
|
||||
}
|
||||
}
|
||||
|
||||
$(theLink).parents('form').append('<input type="hidden" name="' + name + '" value="1" />');
|
||||
} else if (typeof(theLink.href) !== 'undefined') {
|
||||
if (typeof(theLink.href) !== 'undefined') {
|
||||
theLink.href += '&is_js_confirmed=1';
|
||||
} else if (typeof(theLink.form) !== 'undefined') {
|
||||
theLink.form.action += '?is_js_confirmed=1';
|
||||
@ -4074,7 +4063,6 @@ AJAX.registerOnload('functions.js', function () {
|
||||
*/
|
||||
AJAX.registerTeardown('functions.js', function () {
|
||||
$(document).off('change', 'select.pageselector');
|
||||
$(document).off('click', 'a.formLinkSubmit');
|
||||
$('#update_recent_tables').off('ready');
|
||||
$('#sync_favorite_tables').off('ready');
|
||||
});
|
||||
@ -4119,16 +4107,6 @@ AJAX.registerOnload('functions.js', function () {
|
||||
*/
|
||||
PMA_init_slider();
|
||||
|
||||
/**
|
||||
* Enables the text generated by PhpMyAdmin\Util::linkOrButton() to be clickable
|
||||
*/
|
||||
$(document).on('click', 'a.formLinkSubmit', function (e) {
|
||||
if (! $(this).hasClass('requireConfirm')) {
|
||||
submitFormLink($(this));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
var $updateRecentTables = $('#update_recent_tables');
|
||||
if ($updateRecentTables.length) {
|
||||
$.get(
|
||||
|
||||
@ -221,9 +221,6 @@ AJAX.registerTeardown('gis_data_editor.js', function () {
|
||||
});
|
||||
|
||||
AJAX.registerOnload('gis_data_editor.js', function () {
|
||||
// Remove the class that is added due to the URL being too long.
|
||||
$('span.open_gis_editor a').removeClass('formLinkSubmit');
|
||||
|
||||
/**
|
||||
* Prepares and insert the GIS data to the input field on clicking 'copy'.
|
||||
*/
|
||||
|
||||
26
js/sql.js
26
js/sql.js
@ -187,22 +187,18 @@ AJAX.registerOnload('sql.js', function () {
|
||||
var $link = $(this);
|
||||
$link.PMA_confirm(question, $link.attr('href'), function (url) {
|
||||
$msgbox = PMA_ajaxShowMessage();
|
||||
if ($link.hasClass('formLinkSubmit')) {
|
||||
submitFormLink($link);
|
||||
} else {
|
||||
var params = {
|
||||
'ajax_request': true,
|
||||
'is_js_confirmed': true
|
||||
};
|
||||
$.post(url, params, function (data) {
|
||||
if (data.success) {
|
||||
PMA_ajaxShowMessage(data.message);
|
||||
$link.closest('tr').remove();
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
});
|
||||
var params = 'ajax_request=1&is_js_confirmed=1';
|
||||
if ($link.attr('data-post')) {
|
||||
params += '&' + $link.attr('data-post');
|
||||
}
|
||||
$.post(url, params, function (data) {
|
||||
if (data.success) {
|
||||
PMA_ajaxShowMessage(data.message);
|
||||
$link.closest('tr').remove();
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -1863,9 +1863,7 @@ class Results
|
||||
. $tmp_txt . '" title="' . $tmp_txt . '" />';
|
||||
$tmp_url = 'sql.php' . Url::getCommon($url_params_full_text);
|
||||
|
||||
return Util::linkOrButton(
|
||||
$tmp_url, $tmp_image, array(), false
|
||||
);
|
||||
return Util::linkOrButton($tmp_url, $tmp_image);
|
||||
|
||||
} // end of the '_getFullOrPartialTextButtonOrLink()' function
|
||||
|
||||
@ -2324,8 +2322,7 @@ class Results
|
||||
. '<input type="hidden" value="' . $multi_order_url . '" />';
|
||||
|
||||
return Util::linkOrButton(
|
||||
$order_url, $inner_link_content,
|
||||
$order_link_params, false, true
|
||||
$order_url, $inner_link_content, $order_link_params
|
||||
);
|
||||
|
||||
} // end of the '_getSortOrderLink()' function
|
||||
@ -4978,7 +4975,7 @@ class Results
|
||||
Util::getIcon(
|
||||
'b_view_add.png', __('Create view'), true
|
||||
),
|
||||
array('class' => 'create_view' . $ajax_class), true, true, ''
|
||||
array('class' => 'create_view' . $ajax_class)
|
||||
)
|
||||
. '</span>' . "\n";
|
||||
}
|
||||
@ -5024,10 +5021,7 @@ class Results
|
||||
Util::getIcon(
|
||||
'b_insrow.png', __('Copy to clipboard'), true
|
||||
),
|
||||
array('id' => 'copyToClipBoard'),
|
||||
true,
|
||||
true,
|
||||
'copy_to_clip_board'
|
||||
array('id' => 'copyToClipBoard')
|
||||
);
|
||||
|
||||
return $html;
|
||||
@ -5048,8 +5042,6 @@ class Results
|
||||
'b_print.png', __('Print'), true
|
||||
),
|
||||
array('id' => 'printView'),
|
||||
true,
|
||||
true,
|
||||
'print_view'
|
||||
);
|
||||
|
||||
@ -5154,11 +5146,7 @@ class Results
|
||||
'tbl_export.php' . Url::getCommon($_url_params),
|
||||
Util::getIcon(
|
||||
'b_tblexport.png', __('Export'), true
|
||||
),
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
''
|
||||
)
|
||||
)
|
||||
. "\n";
|
||||
|
||||
@ -5167,11 +5155,7 @@ class Results
|
||||
'tbl_chart.php' . Url::getCommon($_url_params),
|
||||
Util::getIcon(
|
||||
'b_chart.png', __('Display chart'), true
|
||||
),
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
''
|
||||
)
|
||||
)
|
||||
. "\n";
|
||||
|
||||
@ -5192,11 +5176,7 @@ class Results
|
||||
. Url::getCommon($_url_params),
|
||||
Util::getIcon(
|
||||
'b_globe.gif', __('Visualize GIS data'), true
|
||||
),
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
''
|
||||
)
|
||||
)
|
||||
. "\n";
|
||||
}
|
||||
@ -5621,9 +5601,7 @@ class Results
|
||||
|
||||
$ret .= '<td class="' . $class . ' center print_ignore" '
|
||||
. ' ><span class="nowrap">'
|
||||
. Util::linkOrButton(
|
||||
$edit_url, $edit_str, array(), false
|
||||
);
|
||||
. Util::linkOrButton($edit_url, $edit_str);
|
||||
/*
|
||||
* Where clause for selecting this row uniquely is provided as
|
||||
* a hidden input. Used by jQuery scripts for handling grid editing
|
||||
@ -5668,9 +5646,7 @@ class Results
|
||||
}
|
||||
|
||||
$ret .= 'center print_ignore" ' . ' ><span class="nowrap">'
|
||||
. Util::linkOrButton(
|
||||
$copy_url, $copy_str, array(), false
|
||||
);
|
||||
. Util::linkOrButton($copy_url, $copy_str);
|
||||
|
||||
/*
|
||||
* Where clause for selecting this row uniquely is provided as
|
||||
@ -5719,8 +5695,7 @@ class Results
|
||||
. Util::linkOrButton(
|
||||
$del_url,
|
||||
$del_str,
|
||||
array('class' => 'delete_row requireConfirm' . $ajax),
|
||||
false
|
||||
array('class' => 'delete_row requireConfirm' . $ajax)
|
||||
)
|
||||
. '<div class="hide">' . $js_conf . '</div>'
|
||||
. '</td>';
|
||||
|
||||
@ -1433,7 +1433,7 @@ class InsertEdit
|
||||
$edit_str = Util::getIcon('b_edit.png', __('Edit/Insert'));
|
||||
return '<span class="open_gis_editor">'
|
||||
. Util::linkOrButton(
|
||||
'#', $edit_str, array(), false, false, '_blank'
|
||||
'#', $edit_str, array(), '_blank'
|
||||
)
|
||||
. '</span>';
|
||||
}
|
||||
|
||||
@ -1052,8 +1052,6 @@ class Util
|
||||
htmlspecialchars('url.php?url=' . urlencode($url)),
|
||||
sprintf(__('Analyze Explain at %s'), 'mariadb.org'),
|
||||
array(),
|
||||
true,
|
||||
false,
|
||||
'_blank'
|
||||
) . ' ]';
|
||||
}
|
||||
@ -1083,34 +1081,23 @@ class Util
|
||||
$php_link = ' [ '
|
||||
. self::linkOrButton(
|
||||
'import.php' . Url::getCommon($url_params),
|
||||
__('Without PHP code'),
|
||||
array(),
|
||||
true,
|
||||
false,
|
||||
'',
|
||||
true
|
||||
__('Without PHP code')
|
||||
)
|
||||
. ' ]';
|
||||
|
||||
$php_link .= ' [ '
|
||||
. self::linkOrButton(
|
||||
'import.php' . Url::getCommon($url_params),
|
||||
__('Submit query'),
|
||||
array(),
|
||||
true,
|
||||
false,
|
||||
'',
|
||||
true
|
||||
__('Submit query')
|
||||
)
|
||||
. ' ]';
|
||||
} else {
|
||||
$php_params = $url_params;
|
||||
$php_params['show_as_php'] = 1;
|
||||
$_message = __('Create PHP code');
|
||||
$php_link = ' [ '
|
||||
. self::linkOrButton(
|
||||
'import.php' . Url::getCommon($php_params),
|
||||
$_message
|
||||
__('Create PHP code')
|
||||
)
|
||||
. ' ]';
|
||||
}
|
||||
@ -1703,26 +1690,26 @@ class Util
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a link, or a button if the link's URL is too large, to
|
||||
* accommodate some browsers' limitations
|
||||
* Displays a link, or a link with code to trigger POST request.
|
||||
*
|
||||
* POST is used in following cases:
|
||||
*
|
||||
* - URL is too long
|
||||
* - URL components are over Suhosin limits
|
||||
* - There is SQL query in the parameters
|
||||
*
|
||||
* @param string $url the URL
|
||||
* @param string $message the link message
|
||||
* @param mixed $tag_params string: js confirmation
|
||||
* array: additional tag params (f.e. style="")
|
||||
* @param boolean $new_form we set this to false when we are already in
|
||||
* a form, to avoid generating nested forms
|
||||
* @param boolean $strip_img whether to strip the image
|
||||
* @param string $target target
|
||||
* @param boolean $force_button use a button even when the URL is not too long
|
||||
*
|
||||
* @return string the results to be echoed or saved in an array
|
||||
*/
|
||||
public static function linkOrButton(
|
||||
$url, $message, $tag_params = array(),
|
||||
$new_form = true, $strip_img = false, $target = '', $force_button = false
|
||||
$url, $message, $tag_params = array(), $target = ''
|
||||
) {
|
||||
$url_length = mb_strlen($url);
|
||||
$url_length = strlen($url);
|
||||
|
||||
if (! is_array($tag_params)) {
|
||||
$tmp = $tag_params;
|
||||
@ -1734,25 +1721,12 @@ class Util
|
||||
unset($tmp);
|
||||
}
|
||||
if (! empty($target)) {
|
||||
$tag_params['target'] = htmlentities($target);
|
||||
$tag_params['target'] = $target;
|
||||
if ($target === '_blank' && strncmp($url, 'url.php?', 8) == 0) {
|
||||
$tag_params['rel'] = 'noopener noreferrer';
|
||||
}
|
||||
}
|
||||
|
||||
$displayed_message = '';
|
||||
// Add text if not already added
|
||||
if (stristr($message, '<img')
|
||||
&& (! $strip_img || ($GLOBALS['cfg']['ActionLinksMode'] == 'icons'))
|
||||
&& (strip_tags($message) == $message)
|
||||
) {
|
||||
$displayed_message = '<span>'
|
||||
. htmlspecialchars(
|
||||
preg_replace('/^.*\salt="([^"]*)".*$/si', '\1', $message)
|
||||
)
|
||||
. '</span>';
|
||||
}
|
||||
|
||||
// Suhosin: Check that each query parameter is not above maximum
|
||||
$in_suhosin_limits = true;
|
||||
if ($url_length <= $GLOBALS['cfg']['LinkLengthLimit']) {
|
||||
@ -1765,7 +1739,7 @@ class Util
|
||||
}
|
||||
|
||||
list(, $eachval) = explode('=', $query_pair);
|
||||
if (mb_strlen($eachval) > $suhosin_get_MaxValueLength
|
||||
if (strlen($eachval) > $suhosin_get_MaxValueLength
|
||||
) {
|
||||
$in_suhosin_limits = false;
|
||||
break;
|
||||
@ -1774,81 +1748,28 @@ class Util
|
||||
}
|
||||
}
|
||||
|
||||
if (($url_length <= $GLOBALS['cfg']['LinkLengthLimit'])
|
||||
&& $in_suhosin_limits
|
||||
&& ! $force_button
|
||||
$tag_params_strings = array();
|
||||
if (($url_length > $GLOBALS['cfg']['LinkLengthLimit'])
|
||||
|| ! $in_suhosin_limits
|
||||
|| strpos($url, 'sql_query=') !== false
|
||||
) {
|
||||
$tag_params_strings = array();
|
||||
foreach ($tag_params as $par_name => $par_value) {
|
||||
$tag_params_strings[] = $par_name . '="' . htmlspecialchars($par_value) . '"';
|
||||
}
|
||||
$parts = explode('?', $url, 2);
|
||||
/*
|
||||
* The data-post indicates that client should do POST
|
||||
* this is handled in js/ajax.js
|
||||
*/
|
||||
$tag_params_strings[] = 'data-post="' . (isset($parts[1]) ? $parts[1] : '') . '"';
|
||||
$url = $parts[0];
|
||||
}
|
||||
|
||||
// no whitespace within an <a> else Safari will make it part of the link
|
||||
$ret = '<a href="' . $url . '" '
|
||||
. implode(' ', $tag_params_strings) . '>'
|
||||
. $message . $displayed_message . '</a>';
|
||||
} else {
|
||||
// no spaces (line breaks) at all
|
||||
// or after the hidden fields
|
||||
// IE will display them all
|
||||
foreach ($tag_params as $par_name => $par_value) {
|
||||
$tag_params_strings[] = $par_name . '="' . htmlspecialchars($par_value) . '"';
|
||||
}
|
||||
|
||||
if (! isset($query_parts)) {
|
||||
$query_parts = self::splitURLQuery($url);
|
||||
}
|
||||
$url_parts = parse_url($url);
|
||||
|
||||
if ($new_form) {
|
||||
if ($target) {
|
||||
$target = ' target="' . $target . '"';
|
||||
}
|
||||
$ret = '<form action="' . $url_parts['path'] . '" class="link"'
|
||||
. ' method="post"' . $target . ' style="display: inline;">';
|
||||
$ret .= Url::getHiddenInputs();
|
||||
$subname_open = '';
|
||||
$subname_close = '';
|
||||
$submit_link = '#';
|
||||
} else {
|
||||
$query_parts[] = 'redirect=' . $url_parts['path'];
|
||||
$query_parts[] = 'token=' . $_SESSION[' PMA_token '];
|
||||
if (empty($GLOBALS['subform_counter'])) {
|
||||
$GLOBALS['subform_counter'] = 0;
|
||||
}
|
||||
$GLOBALS['subform_counter']++;
|
||||
$ret = '';
|
||||
$subname_open = 'subform[' . $GLOBALS['subform_counter'] . '][';
|
||||
$subname_close = ']';
|
||||
$submit_link = '#usesubform[' . $GLOBALS['subform_counter']
|
||||
. ']=1';
|
||||
}
|
||||
|
||||
foreach ($query_parts as $query_pair) {
|
||||
list($eachvar, $eachval) = explode('=', $query_pair);
|
||||
$ret .= '<input type="hidden" name="' . $subname_open . $eachvar
|
||||
. $subname_close . '" value="'
|
||||
. htmlspecialchars(urldecode($eachval)) . '" />';
|
||||
} // end while
|
||||
|
||||
if (empty($tag_params['class'])) {
|
||||
$tag_params['class'] = 'formLinkSubmit';
|
||||
} else {
|
||||
$tag_params['class'] .= ' formLinkSubmit';
|
||||
}
|
||||
|
||||
$tag_params_strings = array();
|
||||
foreach ($tag_params as $par_name => $par_value) {
|
||||
$tag_params_strings[] = $par_name . '="' . htmlspecialchars($par_value) . '"';
|
||||
}
|
||||
|
||||
$ret .= "\n" . '<a href="' . $submit_link . '" '
|
||||
. implode(' ', $tag_params_strings) . '>'
|
||||
. $message . ' ' . $displayed_message . '</a>' . "\n";
|
||||
|
||||
if ($new_form) {
|
||||
$ret .= '</form>';
|
||||
}
|
||||
} // end if... else...
|
||||
|
||||
return $ret;
|
||||
// no whitespace within an <a> else Safari will make it part of the link
|
||||
return '<a href="' . $url . '" '
|
||||
. implode(' ', $tag_params_strings) . '>'
|
||||
. $message . '</a>';
|
||||
} // end of the 'linkOrButton()' function
|
||||
|
||||
/**
|
||||
|
||||
@ -145,59 +145,6 @@ foreach (get_defined_vars() as $key => $value) {
|
||||
}
|
||||
unset($key, $value, $variables_whitelist);
|
||||
|
||||
/**
|
||||
* Subforms - some functions need to be called by form, cause of the limited URL
|
||||
* length, but if this functions inside another form you cannot just open a new
|
||||
* form - so phpMyAdmin uses 'arrays' inside this form
|
||||
*
|
||||
* <code>
|
||||
* <form ...>
|
||||
* ... main form elements ...
|
||||
* <input type="hidden" name="subform[action1][id]" value="1" />
|
||||
* ... other subform data ...
|
||||
* <input type="submit" name="usesubform[action1]" value="do action1" />
|
||||
* ... other subforms ...
|
||||
* <input type="hidden" name="subform[actionX][id]" value="X" />
|
||||
* ... other subform data ...
|
||||
* <input type="submit" name="usesubform[actionX]" value="do actionX" />
|
||||
* ... main form elements ...
|
||||
* <input type="submit" name="main_action" value="submit form" />
|
||||
* </form>
|
||||
* </code>
|
||||
*
|
||||
* so we now check if a subform is submitted
|
||||
*/
|
||||
$__redirect = null;
|
||||
if (isset($_POST['usesubform']) && ! defined('PMA_MINIMUM_COMMON')) {
|
||||
// if a subform is present and should be used
|
||||
// the rest of the form is deprecated
|
||||
$subform_id = key($_POST['usesubform']);
|
||||
$subform = $_POST['subform'][$subform_id];
|
||||
$_POST = $subform;
|
||||
$_REQUEST = $subform;
|
||||
/**
|
||||
* some subforms need another page than the main form, so we will just
|
||||
* include this page at the end of this script - we use $__redirect to
|
||||
* track this
|
||||
*/
|
||||
if (isset($_POST['redirect'])
|
||||
&& $_POST['redirect'] != basename($PMA_PHP_SELF)
|
||||
) {
|
||||
$__redirect = $_POST['redirect'];
|
||||
unset($_POST['redirect']);
|
||||
}
|
||||
unset($subform_id, $subform);
|
||||
} else {
|
||||
// Note: here we overwrite $_REQUEST so that it does not contain cookies,
|
||||
// because another application for the same domain could have set
|
||||
// a cookie (with a compatible path) that overrides a variable
|
||||
// we expect from GET or POST.
|
||||
// We'll refer to cookies explicitly with the $_COOKIE syntax.
|
||||
$_REQUEST = array_merge($_GET, $_POST);
|
||||
}
|
||||
// end check if a subform is submitted
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* parsing configuration file LABEL_parsing_config_file */
|
||||
|
||||
@ -300,13 +247,6 @@ $goto_whitelist = array(
|
||||
'user_password.php',
|
||||
);
|
||||
|
||||
/**
|
||||
* check $__redirect against whitelist
|
||||
*/
|
||||
if (! Core::checkPageValidity($__redirect, $goto_whitelist)) {
|
||||
$__redirect = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* holds page that should be displayed
|
||||
* @global string $GLOBALS['goto']
|
||||
@ -634,14 +574,6 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
/* Tell tracker that it can actually work */
|
||||
Tracker::enable();
|
||||
|
||||
if (!empty($__redirect) && in_array($__redirect, $goto_whitelist)) {
|
||||
/**
|
||||
* include subform target page
|
||||
*/
|
||||
include $__redirect;
|
||||
exit();
|
||||
}
|
||||
|
||||
// If Zero configuration mode enabled, check PMA tables in current db.
|
||||
if (! defined('PMA_MINIMUM_COMMON')
|
||||
&& ! empty($GLOBALS['server'])
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
{% set edit_url = 'gis_data_editor.php' ~ Url_getCommon() %}
|
||||
{% set edit_str = Util_getIcon('b_edit.png', 'Edit/Insert'|trans) %}
|
||||
<span class="open_search_gis_editor">
|
||||
{{ Util_linkOrButton(edit_url, edit_str, [], false, false, '_blank') }}
|
||||
{{ Util_linkOrButton(edit_url, edit_str, [], '_blank') }}
|
||||
</span>
|
||||
{% endif %}
|
||||
{% elseif column_type starts with 'enum'
|
||||
|
||||
@ -438,11 +438,11 @@ class ResultsTest extends PmaTestCase
|
||||
'%60customer%60.%60id%60+%3D+1',
|
||||
'<td class="klass edit_row_anchor center print_ignore" >'
|
||||
. '<span class="nowrap">'
|
||||
. '<a href="tbl_change.php?db=Data&table=customer&where_'
|
||||
. '<a href="tbl_change.php" data-post="db=Data&table=customer&where_'
|
||||
. 'clause=%60customer%60.%60id%60+%3D+1&clause_is_unique=1&'
|
||||
. 'sql_query=SELECT+%2A+FROM+%60customer%60&goto=sql.php&'
|
||||
. 'default_action=update"'
|
||||
. ' ><span class="nowrap"><img src="themes/dot.gif" title="Edit" '
|
||||
. '><span class="nowrap"><img src="themes/dot.gif" title="Edit" '
|
||||
. 'alt="Edit" class="icon ic_b_edit" /> Edit</span></a>'
|
||||
. '<input type="hidden" class="where_clause" value ="%60customer'
|
||||
. '%60.%60id%60+%3D+1" /></span></td>'
|
||||
@ -501,11 +501,11 @@ class ResultsTest extends PmaTestCase
|
||||
'klass',
|
||||
'<td class="klass center print_ignore" ><span class='
|
||||
. '"nowrap">'
|
||||
. '<a href="tbl_change.php?db=Data&table=customer&where_'
|
||||
. '<a href="tbl_change.php" data-post="db=Data&table=customer&where_'
|
||||
. 'clause=%60customer%60.%60id%60+%3D+1&clause_is_unique=1&'
|
||||
. 'sql_query=SELECT+%2A+FROM+%60customer%60&goto=sql.php&'
|
||||
. 'default_action=insert"'
|
||||
. ' ><span class="nowrap"><img src="themes/dot.gif" title="Copy" '
|
||||
. '><span class="nowrap"><img src="themes/dot.gif" title="Copy" '
|
||||
. 'alt="Copy" class="icon ic_b_insrow" /> Copy</span></a>'
|
||||
. '<input type="hidden" class="where_clause" value="%60customer%60'
|
||||
. '.%60id%60+%3D+1" /></span></td>'
|
||||
@ -564,7 +564,7 @@ class ResultsTest extends PmaTestCase
|
||||
'DELETE FROM `Data`.`customer` WHERE `customer`.`id` = 1',
|
||||
'klass',
|
||||
'<td class="klass center print_ignore" >'
|
||||
. '<a href="sql.php?db=Data&table=customer&sql_query=DELETE'
|
||||
. '<a href="sql.php" data-post="db=Data&table=customer&sql_query=DELETE'
|
||||
. '+FROM+%60Data%60.%60customer%60+WHERE+%60customer%60.%60id%60+%3D'
|
||||
. '+1&message_to_show=The+row+has+been+deleted&goto=sql.php'
|
||||
. '%3Fdb%3DData%26table%3Dcustomer%26sql_query%3DSELECT%2B%252A%2B'
|
||||
@ -660,24 +660,24 @@ class ResultsTest extends PmaTestCase
|
||||
. '"condition_array" value="{"`new`.`id`":"= 1"'
|
||||
. '}" /> </td><td class="edit_row_anchor center print_ignore" ><span class='
|
||||
. '"nowrap">'
|
||||
. '<a href="tbl_change.php?db=data&table=new&where_'
|
||||
. '<a href="tbl_change.php" data-post="db=data&table=new&where_'
|
||||
. 'clause=%60new%60.%60id%60+%3D+1&clause_is_unique=1&'
|
||||
. 'sql_query=SELECT+%2A+FROM+%60new%60&goto=sql.php&default'
|
||||
. '_action=update" >'
|
||||
. '_action=update">'
|
||||
. '<span class="nowrap"><img src="themes/dot.gif" title="Edit" '
|
||||
. 'alt="Edit" class="icon ic_b_edit" /> Edit</span></a>'
|
||||
. '<input type="hidden" class="where_clause" value ="%60new%60.%60'
|
||||
. 'id%60+%3D+1" /></span></td><td class="center print_ignore" ><span class'
|
||||
. '="nowrap">'
|
||||
. '<a href="tbl_change.php?db=data&table=new&where_clause'
|
||||
. '<a href="tbl_change.php" data-post="db=data&table=new&where_clause'
|
||||
. '=%60new%60.%60id%60+%3D+1&clause_is_unique=1&sql_query='
|
||||
. 'SELECT+%2A+FROM+%60new%60&goto=sql.php&default_action='
|
||||
. 'insert" ><span class'
|
||||
. 'insert"><span class'
|
||||
. '="nowrap"><img src="themes/dot.gif" title="Copy" alt="Copy" '
|
||||
. 'class="icon ic_b_insrow" /> Copy</span></a>'
|
||||
. '<input type="hidden" class="where_clause" value="%60new%60.%60id'
|
||||
. '%60+%3D+1" /></span></td><td class="center print_ignore" >'
|
||||
. '<a href="sql.php?db=data&table=new&sql_query=DELETE+'
|
||||
. '<a href="sql.php" data-post="db=data&table=new&sql_query=DELETE+'
|
||||
. 'FROM+%60data%60.%60new%60+WHERE+%60new%60.%60id%60+%3D+1&'
|
||||
. 'message_to_show=The+row+has+been+deleted&goto=sql.php%3F'
|
||||
. 'db%3Ddata%26table%3Dnew%26sql_query%3DSELECT%2B%252A%2BFROM%2B'
|
||||
@ -727,7 +727,7 @@ class ResultsTest extends PmaTestCase
|
||||
. 'alt="Delete" class="icon ic_b_drop" /> Delete</span>',
|
||||
'DELETE FROM `data`.`new` WHERE `new`.`id` = 1',
|
||||
'<td class="center print_ignore" >'
|
||||
. '<a href="sql.php?db=data&table=new&sql_query=DELETE+'
|
||||
. '<a href="sql.php" data-post="db=data&table=new&sql_query=DELETE+'
|
||||
. 'FROM+%60data%60.%60new%60+WHERE+%60new%60.%60id%60+%3D+1&'
|
||||
. 'message_to_show=The+row+has+been+deleted&goto=sql.php%3Fdb'
|
||||
. '%3Ddata%26table%3Dnew%26sql_query%3DSELECT%2B%252A%2BFROM%2B%25'
|
||||
@ -737,19 +737,19 @@ class ResultsTest extends PmaTestCase
|
||||
. '"Delete" alt="Delete" class="icon ic_b_drop" /> Delete</span></a>'
|
||||
. '<div class="hide">DELETE FROM `data`.`new` WHERE `new`.'
|
||||
. '`id` = 1</div></td><td class="center print_ignore" ><span class="nowrap">'
|
||||
. '<a href="tbl_change.php?db=data&table=new&where_'
|
||||
. '<a href="tbl_change.php" data-post="db=data&table=new&where_'
|
||||
. 'clause=%60new%60.%60id%60+%3D+1&clause_is_unique=1&sql_'
|
||||
. 'query=SELECT+%2A+FROM+%60new%60&goto=sql.php&default_'
|
||||
. 'action=insert" ><span '
|
||||
. 'action=insert"><span '
|
||||
. 'class="nowrap"><img src="themes/dot.gif" title="Copy" alt="Copy" '
|
||||
. 'class="icon ic_b_insrow" /> Copy</span></a>'
|
||||
. '<input type="hidden" class="where_clause" value="%60new%60.%60id'
|
||||
. '%60+%3D+1" /></span></td><td class="edit_row_anchor center print_ignore" >'
|
||||
. '<span class="nowrap">'
|
||||
. '<a href="tbl_change.php?db=data&table=new&where_clause'
|
||||
. '<a href="tbl_change.php" data-post="db=data&table=new&where_clause'
|
||||
. '=%60new%60.%60id%60+%3D+1&clause_is_unique=1&sql_query='
|
||||
. 'SELECT+%2A+FROM+%60new%60&goto=sql.php&default_action='
|
||||
. 'update" ><span class='
|
||||
. 'update"><span class='
|
||||
. '"nowrap"><img src="themes/dot.gif" title="Edit" alt="Edit" class'
|
||||
. '="icon ic_b_edit" /> Edit</span></a>'
|
||||
. '<input type="hidden" class="where_clause" value ="%60new%60.%60'
|
||||
@ -882,7 +882,7 @@ class ResultsTest extends PmaTestCase
|
||||
'tbl_change.php?db=data&table=new&where_clause=%60new%60.%60'
|
||||
. 'id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+FROM+'
|
||||
. '%60new%60&goto=sql.php&default_action=update',
|
||||
'tbl_change.php?db=data&table=new&where_clause=%60new%60.%60'
|
||||
'/tbl_change.php?db=data&table=new&where_clause=%60new%60.%60'
|
||||
. 'id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+FROM+'
|
||||
. '%60new%60&goto=sql.php&default_action=insert',
|
||||
'edit_row_anchor',
|
||||
|
||||
@ -2172,4 +2172,57 @@ class UtilTest extends PmaTestCase
|
||||
$no_support_types, Util::unsupportedDatatypes()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for Util::linkOrButton
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @dataProvider linksOrButtons
|
||||
*/
|
||||
public function testLinkOrButton(array $params, $limit, $match)
|
||||
{
|
||||
$restore = isset($GLOBALS['cfg']['LinkLengthLimit']) ? $GLOBALS['cfg']['LinkLengthLimit'] : 1000;
|
||||
$GLOBALS['cfg']['LinkLengthLimit'] = $limit;
|
||||
try {
|
||||
$result = call_user_func_array(
|
||||
array('PhpMyAdmin\Util', 'linkOrButton'),
|
||||
$params
|
||||
);
|
||||
$this->assertEquals($match, $result);
|
||||
} finally {
|
||||
$GLOBALS['cfg']['LinkLengthLimit'] = $restore;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for Util::linkOrButton test
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function linksOrButtons()
|
||||
{
|
||||
return [
|
||||
[
|
||||
['index.php', 'text'],
|
||||
1000,
|
||||
'<a href="index.php" >text</a>'
|
||||
],
|
||||
[
|
||||
['index.php?some=parameter', 'text'],
|
||||
20,
|
||||
'<a href="index.php" data-post="some=parameter">text</a>',
|
||||
],
|
||||
[
|
||||
['index.php', 'text', [], 'target'],
|
||||
1000,
|
||||
'<a href="index.php" target="target">text</a>',
|
||||
],
|
||||
[
|
||||
['url.php?url=http://phpmyadmin.net/', 'text', [], '_blank'],
|
||||
1000,
|
||||
'<a href="url.php?url=http://phpmyadmin.net/" target="_blank" rel="noopener noreferrer">text</a>',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user