?
avatar vinespie
vinespie
2 Aug 2016

After JHtmlBootstrap modification #3922, tab label contains slashes if language text (example in FR-fr) contains single quote.

Steps to reproduce the issue

1- Go to Administrator -> Extensions -> Langages -> Overrides
2- Add override with single quote :
2016-08-02 14_29_41-languages_ edit override - joomla 3 - administration
3- Go to "Add New Menu Item"
4- Table label contains slash :
2016-08-02 14_32_47-menus_ new item - joomla 3 - administration

Expected result

Tab label whithout slash before single quote

Actual result

2016-08-02 14_32_47-menus_ new item - joomla 3 - administration

System information (as much as possible)

Joomla 3.6.0

Additional comments

It is necessary to add javascript safe when generating bootstrap tab ?
https://github.com/joomla/joomla-cms/blob/staging/layouts/joomla/edit/params.php#L52
$label = JText::_($fieldSet->label, true);

avatar vinespie vinespie - open - 2 Aug 2016
avatar brianteeman brianteeman - change - 2 Aug 2016
Labels Added: ?
avatar brianteeman
brianteeman - comment - 2 Aug 2016

I can confirm it on the menu tab but not the article tab and only when using the ' but not the `

screen shot 2016-08-02 at 09 39 42screen shot 2016-08-02 at 09 39 45


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11400.

avatar brianteeman brianteeman - change - 2 Aug 2016
Status New Confirmed
avatar vinespie
vinespie - comment - 2 Aug 2016

In article tab, chain translation is not javascript safe.

administrator\components\com_content\views\article\tmpl\edit.php line 123
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'images', JText::_('COM_CONTENT_FIELDSET_URLS_AND_IMAGES')); ?>

But possibly same problem in :
administrator\components\com_plugins\views\plugin\tmpl\edit_options.php line 16
administrator\components\com_weblinks\views\weblink\tmpl\edit.php line 38 - 52 - 64
components\com_contact\views\contact\tmpl\default.php line 174

avatar infograf768
infograf768 - comment - 2 Aug 2016

There are many occurences of bootstrap.addTab and none has addslashes added before the JText:: Good find!

it only concerns ' and not ` as this last one is not a quote in the php sense of the term.

avatar brianteeman
brianteeman - comment - 2 Aug 2016

I'm confused because I showed that the URLS and IMAGES tab works ok

avatar infograf768
infograf768 - comment - 2 Aug 2016

issue is that we have 81 bootstrap.addTab in core and adding addslashes() everywhere is not the perfect solution. We may need a better one that would be global. Don't know if possible.

avatar infograf768
infograf768 - comment - 2 Aug 2016

Let me check further

avatar vinespie
vinespie - comment - 2 Aug 2016

in \layouts\libraries\cms\html\bootstrap\addtabscript.php line 19 , there is "json_encode" apply on title.
Maybe a change must be made on this file.

avatar infograf768
infograf768 - comment - 2 Aug 2016

I confirm that reverting the part of #3922 concerning \layouts\libraries\cms\html\bootstrap\addtabscript.php solves the issue

avatar infograf768
infograf768 - comment - 2 Aug 2016

@vinespie

To solve the issue I changed the line 17 to

$li = '<li class="' . $active . '"><a href="#' . $id . '" data-toggle="tab">' . stripslashes($title) . '</a></li>';

can you test this?

avatar vinespie
vinespie - comment - 2 Aug 2016

Yes it solve the issue but for example you also can change "layouts\joomla\edit\params.php" line 52
$label = JText::_($fieldSet->label, true);
by
$label = JText::_($fieldSet->label);

what is the best/correct solution ?

avatar infograf768
infograf768 - comment - 2 Aug 2016

Maybe better in params.php:
If we use the second proposal I guess we also have to change the rest, i.e.

        if (!empty($fieldSet->label))
        {
            $label = JText::_($fieldSet->label);
        }
        else
        {
            $label = strtoupper('JGLOBAL_FIELDSET_' . $name);
            if (JText::_($label) == $label)
            {
                $label = strtoupper($app->input->get('option') . '_' . $name . '_FIELDSET_LABEL');
            }
            $label = JText::_($label);
        }

Can you make a PR?

avatar vinespie
vinespie - comment - 2 Aug 2016

Yes I can do a PR.
It will also correct the problems in other files.

avatar roland-d
roland-d - comment - 2 Aug 2016

What I find very odd is that it doesn't happen on all views. Does this mean we render tabs in different ways in different places?

The jsSafe parameter should only be used if the text string is going to be used in Javascript code which is not the case for tabs.

I agree the fix in the params.php file should be good enough as we don't need Javascript escaping here.

avatar vinespie
vinespie - comment - 2 Aug 2016

Yes I agree
Do not escape the title to add tabs
What I found is that in some views using JText with jsSafe on tab title.

Same issue with jsSafe parameter in components/com_contact/views/contact/tmpl/default.php line 174
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'display-profile', JText::_('COM_CONTACT_PROFILE', true)); ?>

avatar roland-d
roland-d - comment - 2 Aug 2016

@vinespie That may just be copy-paste rather than a conscious decision. As far as I know is the title not used for any Javascript related functions, that is what the ID is for.

avatar vinespie
vinespie - comment - 2 Aug 2016

@roland-d ok, should I do a pull request for each files or all in one ?

avatar roland-d
roland-d - comment - 2 Aug 2016

@vinespie How many files are there?

avatar vinespie
vinespie - comment - 2 Aug 2016

@roland-d 4 files

administrator\components\com_admin\views\profile\tmpl\edit.php
administrator\components\com_plugins\views\plugin\tmpl\edit_options.php
components\com_contact\views\contact\tmpl\default.php
joomla-cms\layouts\joomla\edit\params.php

avatar roland-d
roland-d - comment - 2 Aug 2016

@vinespie Since there are only 4, do it in 1 PR but provide test details per file as that will help testers to see what they need to check. Thanks.

avatar brianteeman
brianteeman - comment - 2 Aug 2016

That will be great - thanks

avatar infograf768
infograf768 - comment - 3 Aug 2016

@vinespie
Can you make the PR towards staging please

avatar infograf768
infograf768 - comment - 3 Aug 2016

If you have no time, I will do.
Take off the part concerning .gitignore

avatar vinespie
vinespie - comment - 3 Aug 2016

@infograf768 Yes you can do it.
I have 3 problems and I block :

  • commit with unknow user
  • go on .gitignore
  • why my PR contains old commits ?

I can write test process.
Thanks

avatar infograf768
infograf768 - comment - 3 Aug 2016

OK, on it now

avatar infograf768
infograf768 - comment - 3 Aug 2016

@vinespie Please add the test instructions in #11409

avatar infograf768 infograf768 - change - 3 Aug 2016
Status Confirmed Closed
Closed_Date 0000-00-00 00:00:00 2016-08-03 07:33:25
Closed_By infograf768
avatar infograf768
infograf768 - comment - 3 Aug 2016
avatar joomla-cms-bot joomla-cms-bot - close - 3 Aug 2016
avatar infograf768
infograf768 - comment - 3 Aug 2016

Closing as we have a PR (Thanks @vinespie


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11400.

Add a Comment

Login with GitHub to post a comment