mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-08 06:01:22 +00:00
GUAC-1172: Upgrade angular-translate to 2.7.2. Configure required sanitization strategy. Use null instead of false for lack of login error.
This commit is contained in:
@@ -36,6 +36,9 @@ angular.module('index').config(['$injector', function($injector) {
|
|||||||
$translateProvider.fallbackLanguage(fallbackLanguages);
|
$translateProvider.fallbackLanguage(fallbackLanguages);
|
||||||
$translateProvider.preferredLanguage(preferenceServiceProvider.preferences.language);
|
$translateProvider.preferredLanguage(preferenceServiceProvider.preferences.language);
|
||||||
|
|
||||||
|
// Escape any HTML in translation strings
|
||||||
|
$translateProvider.useSanitizeValueStrategy('escape');
|
||||||
|
|
||||||
// Load translations via translationLoader service
|
// Load translations via translationLoader service
|
||||||
$translateProvider.useLoader('translationLoader', {
|
$translateProvider.useLoader('translationLoader', {
|
||||||
fallbackLanguages : fallbackLanguages
|
fallbackLanguages : fallbackLanguages
|
||||||
|
@@ -77,7 +77,7 @@ angular.module('login').directive('guacLogin', [function guacLogin() {
|
|||||||
*
|
*
|
||||||
* @type String
|
* @type String
|
||||||
*/
|
*/
|
||||||
$scope.loginError = false;
|
$scope.loginError = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All form values entered by the user, as parameter name/value pairs.
|
* All form values entered by the user, as parameter name/value pairs.
|
||||||
|
@@ -1,36 +1,81 @@
|
|||||||
/*!
|
/*!
|
||||||
* angular-translate - v2.2.0 - 2014-06-03
|
* angular-translate - v2.7.2 - 2015-06-01
|
||||||
* http://github.com/PascalPrecht/angular-translate
|
* http://github.com/angular-translate/angular-translate
|
||||||
* Copyright (c) 2014 ; Licensed MIT
|
* Copyright (c) 2015 ; Licensed MIT
|
||||||
*/
|
*/
|
||||||
angular.module('pascalprecht.translate').constant('TRANSLATE_MF_INTERPOLATION_CACHE', '$translateMessageFormatInterpolation').factory('$translateMessageFormatInterpolation', [
|
(function (root, factory) {
|
||||||
'$cacheFactory',
|
if (typeof define === 'function' && define.amd) {
|
||||||
'TRANSLATE_MF_INTERPOLATION_CACHE',
|
// AMD. Register as an anonymous module unless amdModuleId is set
|
||||||
function ($cacheFactory, TRANSLATE_MF_INTERPOLATION_CACHE) {
|
define([], function () {
|
||||||
var $translateInterpolator = {}, $cache = $cacheFactory.get(TRANSLATE_MF_INTERPOLATION_CACHE), $mf = new MessageFormat(), $identifier = 'messageformat', $sanitizeValueStrategy = null, sanitizeValueStrategies = {
|
return (factory());
|
||||||
escaped: function (params) {
|
});
|
||||||
var result = {};
|
} else if (typeof exports === 'object') {
|
||||||
for (var key in params) {
|
// Node. Does not work with strict CommonJS, but
|
||||||
if (params.hasOwnProperty(key)) {
|
// only CommonJS-like environments that support module.exports,
|
||||||
result[key] = angular.element('<div></div>').text(params[key]).html();
|
// like Node.
|
||||||
}
|
module.exports = factory();
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var sanitizeParams = function (params) {
|
|
||||||
var result;
|
|
||||||
if (angular.isFunction(sanitizeValueStrategies[$sanitizeValueStrategy])) {
|
|
||||||
result = sanitizeValueStrategies[$sanitizeValueStrategy](params);
|
|
||||||
} else {
|
} else {
|
||||||
result = params;
|
factory();
|
||||||
}
|
}
|
||||||
return result;
|
}(this, function () {
|
||||||
};
|
|
||||||
|
angular.module('pascalprecht.translate')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc property
|
||||||
|
* @name pascalprecht.translate.TRANSLATE_MF_INTERPOLATION_CACHE
|
||||||
|
* @requires TRANSLATE_MF_INTERPOLATION_CACHE
|
||||||
|
*
|
||||||
|
* @description
|
||||||
|
* Uses MessageFormat.js to interpolate strings against some values.
|
||||||
|
*/
|
||||||
|
.constant('TRANSLATE_MF_INTERPOLATION_CACHE', '$translateMessageFormatInterpolation')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc object
|
||||||
|
* @name pascalprecht.translate.$translateMessageFormatInterpolation
|
||||||
|
* @requires pascalprecht.translate.TRANSLATE_MF_INTERPOLATION_CACHE
|
||||||
|
*
|
||||||
|
* @description
|
||||||
|
* Uses MessageFormat.js to interpolate strings against some values.
|
||||||
|
*
|
||||||
|
* Be aware to configure a proper sanitization strategy.
|
||||||
|
*
|
||||||
|
* See also:
|
||||||
|
* * {@link pascalprecht.translate.$translateSanitization}
|
||||||
|
* * {@link https://github.com/SlexAxton/messageformat.js}
|
||||||
|
*
|
||||||
|
* @return {object} $translateMessageFormatInterpolation Interpolator service
|
||||||
|
*/
|
||||||
|
.factory('$translateMessageFormatInterpolation', $translateMessageFormatInterpolation);
|
||||||
|
|
||||||
|
function $translateMessageFormatInterpolation($translateSanitization, $cacheFactory, TRANSLATE_MF_INTERPOLATION_CACHE) {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var $translateInterpolator = {},
|
||||||
|
$cache = $cacheFactory.get(TRANSLATE_MF_INTERPOLATION_CACHE),
|
||||||
|
// instantiate with default locale (which is 'en')
|
||||||
|
$mf = new MessageFormat('en'),
|
||||||
|
$identifier = 'messageformat';
|
||||||
|
|
||||||
if (!$cache) {
|
if (!$cache) {
|
||||||
|
// create cache if it doesn't exist already
|
||||||
$cache = $cacheFactory(TRANSLATE_MF_INTERPOLATION_CACHE);
|
$cache = $cacheFactory(TRANSLATE_MF_INTERPOLATION_CACHE);
|
||||||
}
|
}
|
||||||
|
|
||||||
$cache.put('en', $mf);
|
$cache.put('en', $mf);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc function
|
||||||
|
* @name pascalprecht.translate.$translateMessageFormatInterpolation#setLocale
|
||||||
|
* @methodOf pascalprecht.translate.$translateMessageFormatInterpolation
|
||||||
|
*
|
||||||
|
* @description
|
||||||
|
* Sets current locale (this is currently not use in this interpolation).
|
||||||
|
*
|
||||||
|
* @param {string} locale Language key or locale.
|
||||||
|
*/
|
||||||
$translateInterpolator.setLocale = function (locale) {
|
$translateInterpolator.setLocale = function (locale) {
|
||||||
$mf = $cache.get(locale);
|
$mf = $cache.get(locale);
|
||||||
if (!$mf) {
|
if (!$mf) {
|
||||||
@@ -38,25 +83,75 @@ angular.module('pascalprecht.translate').constant('TRANSLATE_MF_INTERPOLATION_CA
|
|||||||
$cache.put(locale, $mf);
|
$cache.put(locale, $mf);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc function
|
||||||
|
* @name pascalprecht.translate.$translateMessageFormatInterpolation#getInterpolationIdentifier
|
||||||
|
* @methodOf pascalprecht.translate.$translateMessageFormatInterpolation
|
||||||
|
*
|
||||||
|
* @description
|
||||||
|
* Returns an identifier for this interpolation service.
|
||||||
|
*
|
||||||
|
* @returns {string} $identifier
|
||||||
|
*/
|
||||||
$translateInterpolator.getInterpolationIdentifier = function () {
|
$translateInterpolator.getInterpolationIdentifier = function () {
|
||||||
return $identifier;
|
return $identifier;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated will be removed in 3.0
|
||||||
|
* @see {@link pascalprecht.translate.$translateSanitization}
|
||||||
|
*/
|
||||||
$translateInterpolator.useSanitizeValueStrategy = function (value) {
|
$translateInterpolator.useSanitizeValueStrategy = function (value) {
|
||||||
$sanitizeValueStrategy = value;
|
$translateSanitization.useStrategy(value);
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
$translateInterpolator.interpolate = function (string, interpolateParams) {
|
|
||||||
interpolateParams = interpolateParams || {};
|
/**
|
||||||
if ($sanitizeValueStrategy) {
|
* @ngdoc function
|
||||||
interpolateParams = sanitizeParams(interpolateParams);
|
* @name pascalprecht.translate.$translateMessageFormatInterpolation#interpolate
|
||||||
}
|
* @methodOf pascalprecht.translate.$translateMessageFormatInterpolation
|
||||||
var interpolatedText = $cache.get(string + angular.toJson(interpolateParams));
|
*
|
||||||
|
* @description
|
||||||
|
* Interpolates given string agains given interpolate params using MessageFormat.js.
|
||||||
|
*
|
||||||
|
* @returns {string} interpolated string.
|
||||||
|
*/
|
||||||
|
$translateInterpolator.interpolate = function (string, interpolationParams) {
|
||||||
|
interpolationParams = interpolationParams || {};
|
||||||
|
interpolationParams = $translateSanitization.sanitize(interpolationParams, 'params');
|
||||||
|
|
||||||
|
var interpolatedText = $cache.get(string + angular.toJson(interpolationParams));
|
||||||
|
|
||||||
|
// if given string wasn't interpolated yet, we do so now and never have to do it again
|
||||||
if (!interpolatedText) {
|
if (!interpolatedText) {
|
||||||
interpolatedText = $mf.compile(string)(interpolateParams);
|
|
||||||
$cache.put(string + angular.toJson(interpolateParams), interpolatedText);
|
// Ensure explicit type if possible
|
||||||
|
// MessageFormat checks the actual type (i.e. for amount based conditions)
|
||||||
|
for (var key in interpolationParams) {
|
||||||
|
if (interpolationParams.hasOwnProperty(key)) {
|
||||||
|
// ensure number
|
||||||
|
var number = parseInt(interpolationParams[key], 10);
|
||||||
|
if (angular.isNumber(number) && ('' + number) === interpolationParams[key]) {
|
||||||
|
interpolationParams[key] = number;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interpolatedText = $mf.compile(string)(interpolationParams);
|
||||||
|
interpolatedText = $translateSanitization.sanitize(interpolatedText, 'text');
|
||||||
|
|
||||||
|
$cache.put(string + angular.toJson(interpolationParams), interpolatedText);
|
||||||
|
}
|
||||||
|
|
||||||
return interpolatedText;
|
return interpolatedText;
|
||||||
};
|
};
|
||||||
|
|
||||||
return $translateInterpolator;
|
return $translateInterpolator;
|
||||||
}
|
}
|
||||||
]);
|
$translateMessageFormatInterpolation.$inject = ['$translateSanitization', '$cacheFactory', 'TRANSLATE_MF_INTERPOLATION_CACHE'];
|
||||||
|
|
||||||
|
$translateMessageFormatInterpolation.displayName = '$translateMessageFormatInterpolation';
|
||||||
|
return 'pascalprecht.translate';
|
||||||
|
|
||||||
|
}));
|
||||||
|
@@ -1,31 +1,114 @@
|
|||||||
/*!
|
/*!
|
||||||
* angular-translate - v2.2.0 - 2014-06-03
|
* angular-translate - v2.7.2 - 2015-06-01
|
||||||
* http://github.com/PascalPrecht/angular-translate
|
* http://github.com/angular-translate/angular-translate
|
||||||
* Copyright (c) 2014 ; Licensed MIT
|
* Copyright (c) 2015 ; Licensed MIT
|
||||||
*/
|
*/
|
||||||
angular.module('pascalprecht.translate').factory('$translateStaticFilesLoader', [
|
(function (root, factory) {
|
||||||
'$q',
|
if (typeof define === 'function' && define.amd) {
|
||||||
'$http',
|
// AMD. Register as an anonymous module unless amdModuleId is set
|
||||||
function ($q, $http) {
|
define([], function () {
|
||||||
return function (options) {
|
return (factory());
|
||||||
if (!options || (!angular.isString(options.prefix) || !angular.isString(options.suffix))) {
|
});
|
||||||
throw new Error('Couldn\'t load static files, no prefix or suffix specified!');
|
} else if (typeof exports === 'object') {
|
||||||
|
// Node. Does not work with strict CommonJS, but
|
||||||
|
// only CommonJS-like environments that support module.exports,
|
||||||
|
// like Node.
|
||||||
|
module.exports = factory();
|
||||||
|
} else {
|
||||||
|
factory();
|
||||||
}
|
}
|
||||||
|
}(this, function () {
|
||||||
|
|
||||||
|
angular.module('pascalprecht.translate')
|
||||||
|
/**
|
||||||
|
* @ngdoc object
|
||||||
|
* @name pascalprecht.translate.$translateStaticFilesLoader
|
||||||
|
* @requires $q
|
||||||
|
* @requires $http
|
||||||
|
*
|
||||||
|
* @description
|
||||||
|
* Creates a loading function for a typical static file url pattern:
|
||||||
|
* "lang-en_US.json", "lang-de_DE.json", etc. Using this builder,
|
||||||
|
* the response of these urls must be an object of key-value pairs.
|
||||||
|
*
|
||||||
|
* @param {object} options Options object, which gets prefix, suffix and key.
|
||||||
|
*/
|
||||||
|
.factory('$translateStaticFilesLoader', $translateStaticFilesLoader);
|
||||||
|
|
||||||
|
function $translateStaticFilesLoader($q, $http) {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
return function (options) {
|
||||||
|
|
||||||
|
if (!options || (!angular.isArray(options.files) && (!angular.isString(options.prefix) || !angular.isString(options.suffix)))) {
|
||||||
|
throw new Error('Couldn\'t load static files, no files and prefix or suffix specified!');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!options.files) {
|
||||||
|
options.files = [{
|
||||||
|
prefix: options.prefix,
|
||||||
|
suffix: options.suffix
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
var load = function (file) {
|
||||||
|
if (!file || (!angular.isString(file.prefix) || !angular.isString(file.suffix))) {
|
||||||
|
throw new Error('Couldn\'t load static file, no prefix or suffix specified!');
|
||||||
|
}
|
||||||
|
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
$http({
|
|
||||||
|
$http(angular.extend({
|
||||||
url: [
|
url: [
|
||||||
options.prefix,
|
file.prefix,
|
||||||
options.key,
|
options.key,
|
||||||
options.suffix
|
file.suffix
|
||||||
].join(''),
|
].join(''),
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
params: ''
|
params: ''
|
||||||
}).success(function (data) {
|
}, options.$http)).success(function (data) {
|
||||||
deferred.resolve(data);
|
deferred.resolve(data);
|
||||||
}).error(function (data) {
|
}).error(function () {
|
||||||
deferred.reject(options.key);
|
deferred.reject(options.key);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return deferred.promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
var deferred = $q.defer(),
|
||||||
|
promises = [],
|
||||||
|
length = options.files.length;
|
||||||
|
|
||||||
|
for (var i = 0; i < length; i++) {
|
||||||
|
promises.push(load({
|
||||||
|
prefix: options.files[i].prefix,
|
||||||
|
key: options.key,
|
||||||
|
suffix: options.files[i].suffix
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
$q.all(promises).then(function (data) {
|
||||||
|
var length = data.length,
|
||||||
|
mergedData = {};
|
||||||
|
|
||||||
|
for (var i = 0; i < length; i++) {
|
||||||
|
for (var key in data[i]) {
|
||||||
|
mergedData[key] = data[i][key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
deferred.resolve(mergedData);
|
||||||
|
}, function (data) {
|
||||||
|
deferred.reject(data);
|
||||||
|
});
|
||||||
|
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
]);
|
$translateStaticFilesLoader.$inject = ['$q', '$http'];
|
||||||
|
|
||||||
|
$translateStaticFilesLoader.displayName = '$translateStaticFilesLoader';
|
||||||
|
return 'pascalprecht.translate';
|
||||||
|
|
||||||
|
}));
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user