Skip to content
Permalink
Browse files

Refactor Sanitize Twig extensions

Signed-off-by: Leonardo Strozzi <laps15@inf.ufpr.br>
  • Loading branch information...
laps15 committed Aug 3, 2018
1 parent 1037b1d commit ad3334ccc300a3908dec87811c8144890e47b88d
@@ -10,7 +10,7 @@
namespace PhpMyAdmin\Twig;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
use Twig\TwigFilter;
/**
* Class SanitizeExtension
@@ -20,25 +20,25 @@
class SanitizeExtension extends AbstractExtension
{
/**
* Returns a list of functions to add to the existing list.
* Returns a list of filters to add to the existing list.
*
* @return TwigFunction[]
* @return TwigFilter[]
*/
public function getFunctions()
public function getFilters()
{
return [
new TwigFunction(
'Sanitize_escapeJsString',
new TwigFilter(
'escape_js_string',
'PhpMyAdmin\Sanitize::escapeJsString',
['is_safe' => ['html']]
),
new TwigFunction(
'Sanitize_jsFormat',
new TwigFilter(
'js_format',
'PhpMyAdmin\Sanitize::jsFormat',
['is_safe' => ['html']]
),
new TwigFunction(
'Sanitize_sanitize',
new TwigFilter(
'sanitize',
'PhpMyAdmin\Sanitize::sanitize',
['is_safe' => ['html']]
),
@@ -24,9 +24,7 @@
{# larger values are more interesting so default sort order is DESC #}
<th>
{{ sortable_table_header('Rows'|trans, 'records', 'DESC') }}
{{ show_hint(Sanitize_sanitize(
'May be approximate. Click on the number to get the exact count. See [doc@faq3-11]FAQ 3.11[/doc].'|trans
)) }}
{{ show_hint('May be approximate. Click on the number to get the exact count. See [doc@faq3-11]FAQ 3.11[/doc].'|trans|sanitize) }}
</th>
{% if not (properties_num_columns > 1) %}
<th>{{ sortable_table_header('Type'|trans, 'type') }}</th>
@@ -9,18 +9,12 @@ $( function() {
{% set ajax_url = 'import_status.php?id=' ~ upload_id ~ '&' ~ get_common_raw({
'import_status': 1
}) %}
{% set promot_str = Sanitize_jsFormat(
'The file being uploaded is probably larger than the maximum allowed size or this is a known bug in webkit based (Safari, Google Chrome, Arora etc.) browsers.'|trans,
false
) %}
{% set statustext_str = Sanitize_escapeJsString('%s of %s'|trans) %}
{% set second_str = Sanitize_jsFormat('%s/sec.'|trans, false) %}
{% set remaining_min = Sanitize_jsFormat('About %MIN min. %SEC sec. remaining.'|trans, false) %}
{% set remaining_second = Sanitize_jsFormat('About %SEC sec. remaining.'|trans, false) %}
{% set processed_str = Sanitize_jsFormat(
'The file is being processed, please be patient.'|trans,
false
) %}
{% set promot_str = 'The file being uploaded is probably larger than the maximum allowed size or this is a known bug in webkit based (Safari, Google Chrome, Arora etc.) browsers.'|trans|js_format(false) %}
{% set statustext_str = '%s of %s'|trans|escape_js_string %}
{% set second_str = '%s/sec.'|trans|js_format(false) %}
{% set remaining_min = 'About %MIN min. %SEC sec. remaining.'|trans|js_format(false) %}
{% set remaining_second = 'About %SEC sec. remaining.'|trans|js_format(false) %}
{% set processed_str = 'The file is being processed, please be patient.'|trans|js_format(false) %}
{% set import_url = get_common_raw({'import_status': 1}) %}

{% set upload_html %}
@@ -33,7 +27,7 @@ $( function() {
</div>
</div>
<div>
<img src="{{ pma_theme_image }}ajax_clock_small.gif" width="16" height="16" alt="ajax clock" /> {{ Sanitize_jsFormat('Uploading your import file…'|trans, false) -}}
<img src="{{ pma_theme_image }}ajax_clock_small.gif" width="16" height="16" alt="ajax clock" /> {{ 'Uploading your import file…'|trans|js_format(false) -}}
</div>
<div id="statustext"></div>
</div>
@@ -158,10 +152,7 @@ $( function() {
{% set image_tag -%}
<img src="{{ pma_theme_image -}}
ajax_clock_small.gif" width="16" height="16" alt="ajax clock" />
{{- Sanitize_jsFormat(
'Please be patient, the file is being uploaded. Details about the upload are not available.'|trans,
false
) -}}
{{- 'Please be patient, the file is being uploaded. Details about the upload are not available.'|trans|js_format(false) -}}
{{- show_docu('faq', 'faq2-9') -}}
{%- endset %}
$('#upload_form_status_info').html('{{ image_tag|raw }}');
@@ -8,14 +8,14 @@
<meta http-equiv="Refresh" content="0;url={{ uri }}" />
<script type="text/javascript">
//<![CDATA[
setTimeout(function() { window.location = decodeURI('{{ Sanitize_escapeJsString(uri) }}'); }, 2000);
setTimeout(function() { window.location = decodeURI('{{ uri|escape_js_string }}'); }, 2000);
//]]>
</script>
</head>
<body>
<script type="text/javascript">
//<![CDATA[
document.write('<p><a href="{{ Sanitize_escapeJsString(uri|e) }}">{% trans 'Go' %}</a></p>');
document.write('<p><a href="{{ uri|e|escape_js_string }}">{% trans 'Go' %}</a></p>');
//]]>
</script>
</body>
@@ -43,7 +43,7 @@

<td class="tool">
<a class="server_databases" data="
{{- Sanitize_jsFormat(current['SCHEMA_NAME']) }}" href="server_privileges.php
{{- current['SCHEMA_NAME']|js_format }}" href="server_privileges.php
{{- get_common({
'db': current['SCHEMA_NAME'],
'checkprivsdb': current['SCHEMA_NAME']
@@ -17,11 +17,7 @@
one_key['constraint']
)
} %}
{% set js_msg = Sanitize_jsFormat(
'ALTER TABLE ' ~ db ~ '.' ~ table
~ ' DROP FOREIGN KEY '
~ one_key['constraint'] ~ ';'
) %}
{% set js_msg = 'ALTER TABLE ' ~ db ~ '.' ~ table ~ ' DROP FOREIGN KEY ' ~ one_key['constraint'] ~ ';'|js_format %}
{% endif %}
{% if one_key['constraint'] is defined %}
<input type="hidden" class="drop_foreign_key_msg" value="

0 comments on commit ad3334c

Please sign in to comment.
You can’t perform that action at this time.