Skip to content

Commit

Permalink
ref #7531 Fix a double encoded site name bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Apr 7, 2015
1 parent 9037275 commit 662621b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@

angular.forEach(sites, function (site) {
if (site.group) site.name = '[' + site.group + '] ' + site.name;
if (!site.name) {
return;
}
// Escape site names, see https://github.com/piwik/piwik/issues/7531
site.name = site.name.replace(/[\u0000-\u2666]/g, function(c) {
return '&#'+c.charCodeAt(0)+';';
});
});

model.sites = $filter('orderBy')(sites, '+name');
Expand Down
10 changes: 0 additions & 10 deletions plugins/CoreHome/angularjs/siteselector/siteselector.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
$scope.autocompleteMinSites = AUTOCOMPLETE_MIN_SITES;
$scope.selectedSite = {id: '', name: ''};
$scope.activeSiteId = piwik.idSite;
$scope.selectedSiteNameHtml = '';

$scope.switchSite = function (site) {
$scope.selectedSite = {id: site.idsite, name: site.name};
Expand All @@ -40,15 +39,6 @@
'#' + piwik.helper.getQueryStringWithParametersModified(hash.substring(1), newParameters);
};

$scope.$watch('selectedSite', function (site) {
if (!site.name) {
return;
}
$scope.selectedSiteNameHtml = site.name.replace(/[\u0000-\u2666]/g, function(c) {
return '&#'+c.charCodeAt(0)+';';
});
});

siteSelectorModel.loadInitialSites();
}
})();
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
href="javascript:void(0)"
class="custom_select_main_link"
ng-class="{'loading': model.isLoading}">
<span ng-bind-html="selectedSiteNameHtml || model.firstSiteName">?</span>
<span ng-bind-html="selectedSite.name || model.firstSiteName">?</span>
</a>

<div ng-show="view.showSitesList" class="custom_select_block">
Expand All @@ -29,7 +29,8 @@
ng-repeat="site in model.sites"
ng-hide="!showSelectedSite && activeSiteId==site.idsite">
<a piwik-ignore-click href="{{ getUrlForSiteId(site.idsite) }}"
piwik-autocomplete-matched="view.searchTerm">{{ site.name }}</a>
piwik-autocomplete-matched="view.searchTerm"
ng-bind-html="site.name"></a>
</li>
</ul>
<ul ng-show="!model.sites.length && view.searchTerm" class="ui-autocomplete ui-front ui-menu ui-widget ui-widget-content ui-corner-all siteSelect">
Expand Down
2 changes: 1 addition & 1 deletion plugins/ScheduledReports/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ public function generateReport($idReport, $date, $language = false, $outputType
// render report
$description = str_replace(array("\r", "\n"), ' ', $report['description']);

list($reportSubject, $reportTitle) = self::getReportSubjectAndReportTitle(Site::getNameFor($idSite), $report['reports']);
list($reportSubject, $reportTitle) = self::getReportSubjectAndReportTitle(Common::unsanitizeInputValue(Site::getNameFor($idSite)), $report['reports']);

// if reporting for a segment, use the segment's name in the title
if(is_array($segment) && strlen($segment['name'])) {
Expand Down
2 changes: 2 additions & 0 deletions plugins/SitesManager/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ public function siteWithoutData()
$piwikUrl = Url::getCurrentUrlWithoutFileName();

return $this->renderTemplate('siteWithoutData', array(
'site' => $this->site,
'idSite' => $this->idSite,
'siteName' => $this->site->getName(),
'trackingHelp' => $this->renderTemplate('_displayJavascriptCode', array(
'displaySiteName' => Common::unsanitizeInputValue($this->site->getName()),
Expand Down

0 comments on commit 662621b

Please sign in to comment.