From cbec998d78318539a206befc88ff9e696541da9a Mon Sep 17 00:00:00 2001 From: Stefan Giehl Date: Mon, 5 Dec 2016 18:37:19 +0100 Subject: always unescape escaped % symbols in translations (#10917) * always unescape escaped % symbols in translations * adds new tests to proove %-symbols are escaped in english translations * submodule update --- plugins/Actions/lang/en.json | 2 +- plugins/CustomAlerts | 2 +- .../Test/Integration/LanguagesManagerTest.php | 26 ++++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/Actions/lang/en.json b/plugins/Actions/lang/en.json index c31dc264ec..27c9b2f72f 100644 --- a/plugins/Actions/lang/en.json +++ b/plugins/Actions/lang/en.json @@ -18,7 +18,7 @@ "ColumnSearchCategory": "Search Category", "ColumnSearches": "Searches", "ColumnSearchesDocumentation": "The number of visits that searched for this keyword on your website's search engine.", - "ColumnSearchExits": "% Search Exits", + "ColumnSearchExits": "%% Search Exits", "ColumnSearchExitsDocumentation": "The percentage of visits that left the website after searching for this Keyword on your Site Search engine.", "ColumnSearchResultsCount": "Search Results Count", "ColumnSiteSearchKeywords": "Unique Keywords", diff --git a/plugins/CustomAlerts b/plugins/CustomAlerts index 49ae454fd7..8c861c9084 160000 --- a/plugins/CustomAlerts +++ b/plugins/CustomAlerts @@ -1 +1 @@ -Subproject commit 49ae454fd7eae39e07300c83e0dff40dda2e4276 +Subproject commit 8c861c9084a25dc36e1176496598a175a1619ee9 diff --git a/plugins/LanguagesManager/Test/Integration/LanguagesManagerTest.php b/plugins/LanguagesManager/Test/Integration/LanguagesManagerTest.php index 0ff66919ce..59124a79cd 100755 --- a/plugins/LanguagesManager/Test/Integration/LanguagesManagerTest.php +++ b/plugins/LanguagesManager/Test/Integration/LanguagesManagerTest.php @@ -155,6 +155,32 @@ class LanguagesManagerTest extends \PHPUnit_Framework_TestCase } } + /** + * check all english translations do not contain unescaped % symbols + * + * @group Plugins + * @group numbered2 + */ + function testTranslationsUseEscapedPercentSigns() + { + Cache::flushAll(); + $translator = StaticContainer::get('Piwik\Translation\Translator'); + $translator->reset(); + Translate::loadAllTranslations(); + $translations = $translator->getAllTranslations(); + foreach ($translations AS $plugin => $pluginTranslations) { + if ($plugin == 'Intl') { + continue; // skip generated stuff + } + foreach ($pluginTranslations as $key => $pluginTranslation) { + $pluginTranslation = preg_replace('/(%(?:[1-9]\$)?[a-z])/', '', $pluginTranslation); // remove placeholders + $pluginTranslation = str_replace('%%', '', $pluginTranslation); // remove already escaped symbols + $this->assertEquals(0, substr_count($pluginTranslation, '%'), + sprintf('%s.%s must use escaped %% symbols', $plugin, $key)); + } + } + } + /** * test English short name for language * -- cgit v1.2.3 From c68bdc20c17d51e315f0b88701f3829e8d6108b4 Mon Sep 17 00:00:00 2001 From: sgiehl Date: Mon, 5 Dec 2016 21:08:15 +0100 Subject: show token_auth only on click --- plugins/API/templates/listAllAPI.twig | 2 +- plugins/CoreHome/CoreHome.php | 2 + .../common/directives/show-sensitive-data.js | 59 ++++++++++++++++++++++ plugins/CoreHome/lang/en.json | 1 + plugins/UsersManager/templates/userSettings.twig | 2 +- 5 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 plugins/CoreHome/angularjs/common/directives/show-sensitive-data.js (limited to 'plugins') diff --git a/plugins/API/templates/listAllAPI.twig b/plugins/API/templates/listAllAPI.twig index 258b74c49d..9aa2685881 100644 --- a/plugins/API/templates/listAllAPI.twig +++ b/plugins/API/templates/listAllAPI.twig @@ -20,7 +20,7 @@

{{ 'API_UsingTokenAuth'|translate('','',"")|raw }}
-

&token_auth={{ token_auth }}

+
&token_auth=

{{ 'API_KeepTokenSecret'|translate('','')|raw }}
{{ 'API_ChangeTokenHint'|translate('
+ */ +(function () { + angular.module('piwikApp.directive').directive('piwikShowSensitiveData', piwikShowSensitiveData); + + function piwikShowSensitiveData(){ + return { + restrict: 'A', + link: function(scope, element, attr) { + + var sensitiveData = attr.piwikShowSensitiveData || attr.text(); + var showCharacters = attr.showCharacters || 6; + var clickElement = attr.clickElementSelector || element; + + var protectedData = ''; + if (showCharacters > 0) { + protectedData += sensitiveData.substr(0, showCharacters); + } + protectedData += sensitiveData.substr(showCharacters).replace(/./g, '*'); + element.html(protectedData); + + function onClickHandler(event) { + element.html(sensitiveData); + $(clickElement).css({ + cursor: '' + }); + $(clickElement).tooltip("destroy"); + } + + $(clickElement).tooltip({ + content: _pk_translate('CoreHome_ClickToSeeFullInformation'), + items: '*', + track: true + }); + + $(clickElement).one('click', onClickHandler); + $(clickElement).css({ + cursor: 'pointer' + }) + } + }; + } +})(); diff --git a/plugins/CoreHome/lang/en.json b/plugins/CoreHome/lang/en.json index 808250348e..57c5071c4a 100644 --- a/plugins/CoreHome/lang/en.json +++ b/plugins/CoreHome/lang/en.json @@ -5,6 +5,7 @@ "CheckForUpdates": "Check for updates", "CheckPiwikOut": "Check Piwik out!", "ClickToEditX": "Click to edit %s", + "ClickToSeeFullInformation": "Click to see the full information", "CloseSearch": "Close search", "CloseWidgetDirections": "You can close this widget by clicking on the 'X' icon at the top of the widget.", "ChooseX": "Choose %1$s", diff --git a/plugins/UsersManager/templates/userSettings.twig b/plugins/UsersManager/templates/userSettings.twig index 2824262acd..34a2b5a75a 100644 --- a/plugins/UsersManager/templates/userSettings.twig +++ b/plugins/UsersManager/templates/userSettings.twig @@ -109,7 +109,7 @@
-
{{ userTokenAuth }}
+

 
     

{{ 'UsersManager_TokenRegenerateLogoutWarning'|translate }}

\ No newline at end of file diff --git a/plugins/Marketplace/templates/getNewPluginsAdmin.twig b/plugins/Marketplace/templates/getNewPluginsAdmin.twig index b929a48430..1e3d60f647 100644 --- a/plugins/Marketplace/templates/getNewPluginsAdmin.twig +++ b/plugins/Marketplace/templates/getNewPluginsAdmin.twig @@ -5,7 +5,7 @@

{{ plugin.name }}

+ piwik-plugin-name="{{ plugin.name|e('html_attr') }}">{{ plugin.displayName }}

{{ plugin.description }}

@@ -20,7 +20,7 @@ diff --git a/plugins/Marketplace/templates/getPremiumFeatures.twig b/plugins/Marketplace/templates/getPremiumFeatures.twig new file mode 100644 index 0000000000..fa0fe83744 --- /dev/null +++ b/plugins/Marketplace/templates/getPremiumFeatures.twig @@ -0,0 +1,23 @@ +
+
+ {% for plugin in plugins %} +
+ +

{{ plugin.displayName }}

+ + {{ plugin.description }} +
+ {{ 'General_MoreDetails'|translate }} +
+
+ {% if loop.index % 3 == 0 %} +
+ {% endif %} + {% endfor %} +
+ + +
\ No newline at end of file diff --git a/plugins/Widgetize/tests/System/WidgetTest.php b/plugins/Widgetize/tests/System/WidgetTest.php index af99759c77..e0ff947bf7 100644 --- a/plugins/Widgetize/tests/System/WidgetTest.php +++ b/plugins/Widgetize/tests/System/WidgetTest.php @@ -12,7 +12,6 @@ use Piwik\Container\StaticContainer; use Piwik\Http\ControllerResolver; use Piwik\Piwik; use Piwik\Plugins\API; -use Piwik\Plugins\Goals; use Piwik\Plugins\Widgetize\tests\Fixtures\WidgetizeFixture; use Piwik\Tests\Framework\TestCase\SystemTestCase; use Piwik\Widget\WidgetsList; @@ -992,6 +991,14 @@ class WidgetTest extends SystemTestCase 'module' => 'Marketplace', 'action' => 'getNewPlugins', ), + ), array ( + 'name' => 'Premium Features', + 'uniqueId' => 'widgetMarketplacegetPremiumFeatures', + 'parameters' => + array ( + 'module' => 'Marketplace', + 'action' => 'getPremiumFeatures', + ), ), array ( 'name' => 'System Check', 'uniqueId' => 'widgetInstallationgetSystemCheck', -- cgit v1.2.3 From 388a1000f4b101e47e7458e916c36b65e3774234 Mon Sep 17 00:00:00 2001 From: mattab Date: Wed, 7 Dec 2016 01:16:08 +1300 Subject: Hide Piwik version in UI tests --- plugins/CoreHome/templates/getSystemSummary.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/CoreHome/templates/getSystemSummary.twig b/plugins/CoreHome/templates/getSystemSummary.twig index 75cdf0a935..264162c180 100644 --- a/plugins/CoreHome/templates/getSystemSummary.twig +++ b/plugins/CoreHome/templates/getSystemSummary.twig @@ -14,7 +14,7 @@
{{ 'CoreHome_SystemSummaryPiwikVersion'|translate }}: - {{ piwikVersion }} + {{ piwikVersion }}
{{ 'CoreHome_SystemSummaryMysqlVersion'|translate }}: -- cgit v1.2.3