Fixing javasccript encoding issues

Work Items: 19471

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros 2013-02-22 18:08:52 -08:00
parent f9279e9ac8
commit c6a140fcf0
2 changed files with 18 additions and 17 deletions

View File

@ -32,12 +32,13 @@
.Replace("Y", "y")
.Replace("M", "m")
;
}
@functions {
private string FormatJsList(string csv) {
return "'" + String.Join("', '", csv.Split(',').Select(x => x.Trim())) + "'";
return "'" + String.Join("', '", csv.Split(',').Select(x => HttpUtility.JavaScriptStringEncode(x.Trim()))) + "'";
}
}
@ -45,21 +46,21 @@
//<![CDATA[
$(function() {
$.datepicker.regional[''] = {
closeText: '@T("Done")', // Display text for close link
prevText: '@T("Prev")', // Display text for previous month link
nextText: '@T("Next")', // Display text for next month link
currentText: '@T("Today")', // Display text for current month link
closeText: '@HttpUtility.JavaScriptStringEncode(T("Done").Text)', // Display text for close link
prevText: '@HttpUtility.JavaScriptStringEncode(T("Prev").Text)', // Display text for previous month link
nextText: '@HttpUtility.JavaScriptStringEncode(T("Next").Text)', // Display text for next month link
currentText: '@HttpUtility.JavaScriptStringEncode(T("Today").Text)', // Display text for current month link
monthNames: [@Html.Raw(monthNames)], // Names of months for drop-down and formatting
monthNamesShort: [@Html.Raw(monthNamesShort)], // For formatting
dayNames: [@Html.Raw(dayNames)], // For formatting
dayNamesShort: [@Html.Raw(dayNamesShort)], // For formatting
dayNamesMin: [@Html.Raw(dayNamesMin)], // Column headings for days starting at Sunday
weekHeader: '@T("Wk")', // Column header for week of the year
dateFormat: '@dateFormat', // See format options on parseDate
weekHeader: '@HttpUtility.JavaScriptStringEncode(T("Wk").Text)', // Column header for week of the year
dateFormat: '@HttpUtility.JavaScriptStringEncode(dateFormat)', // See format options on parseDate
firstDay: @dateTimeLocalization.FirstDay, // The first day of the week, Sun = 0, Mon = 1, ...
isRTL: @(cultureInfo.TextInfo.IsRightToLeft ? "true" : "false"), // True if right-to-left language, false if left-to-right
showMonthAfterYear: @(dateTimeLocalization.ShowMonthAfterYear ? "true" : "false"), // True if the year select precedes month, false for month then year
yearSuffix: '@dateTimeLocalization.YearSuffix' // Additional text to append to the year in the month headers
yearSuffix: '@HttpUtility.JavaScriptStringEncode(dateTimeLocalization.YearSuffix)' // Additional text to append to the year in the month headers
};
$.datepicker.setDefaults($.datepicker.regional['']);

View File

@ -9,12 +9,12 @@
}
WorkContext.SetState("TimePickerLocalization", new object());
Style.Require("jQueryUI_TimePicker");
Script.Require("jQueryUI_TimePicker");
var cultureInfo = CultureInfo.GetCultureInfo(WorkContext.CurrentCulture);
var timeFormat = cultureInfo.DateTimeFormat.ShortTimePattern
.Replace("H", "h");
@ -26,13 +26,13 @@
$(function() {
$.timepicker.regional[''] = {
timeOnlyTitle: '@T("Choose time")',
timeText: '@T("Time")',
hourText: '@T("Hour")',
minuteText: '@T("Minute")',
currentText: '@T("Now")', // Display text for current time link
closeText: '@T("Done")', // Display text for close link
timeFormat: '@timeFormat',
timeOnlyTitle: '@HttpUtility.JavaScriptStringEncode(T("Choose time").Text)',
timeText: '@HttpUtility.JavaScriptStringEncode(T("Time").Text)',
hourText: '@HttpUtility.JavaScriptStringEncode(T("Hour").Text)',
minuteText: '@HttpUtility.JavaScriptStringEncode(T("Minute").Text)',
currentText: '@HttpUtility.JavaScriptStringEncode(T("Now").Text)', // Display text for current time link
closeText: '@HttpUtility.JavaScriptStringEncode(T("Done").Text)', // Display text for close link
timeFormat: '@HttpUtility.JavaScriptStringEncode(timeFormat)',
amNames: ['@cultureInfo.DateTimeFormat.AMDesignator', 'AM', 'A'],
pmNames: ['@cultureInfo.DateTimeFormat.PMDesignator', 'PM', 'P'],
ampm: @ampm,