File tree Expand file tree Collapse file tree 3 files changed +31
-14
lines changed Expand file tree Collapse file tree 3 files changed +31
-14
lines changed Original file line number Diff line number Diff line change @@ -199,9 +199,11 @@ export default {
199
199
cancelLabel: this .__ (' common.no' ),
200
200
modalName: ' delete' ,
201
201
title: this .deleteAnnouncementLabel ,
202
- message: this .replaceLocaleParams (this .confirmDeleteMessage , {
203
- title: this .localize (announcement .title )
204
- }),
202
+ message: this .replaceLocaleParams (
203
+ this .confirmDeleteMessage ,
204
+ {title: this .localize (announcement .title )},
205
+ {htmlEscaping: true }
206
+ ),
205
207
callback : () => {
206
208
var self = this ;
207
209
$ .ajax ({
Original file line number Diff line number Diff line change 27
27
<list >
28
28
<list-item >
29
29
{{
30
- replaceLocaleParams(this.subjectLabel, {
31
- subject: item.subject
32
- })
30
+ replaceLocaleParams(
31
+ this.subjectLabel,
32
+ {subject: item.subject},
33
+ {htmlEscaping: true}
34
+ )
33
35
}}
34
36
</list-item >
35
37
<list-item v-if =" item.fromRoleId" >
36
38
{{
37
- replaceLocaleParams(this.fromLabel, {
38
- value: getRoleLabel(item.fromRoleId)
39
- })
39
+ replaceLocaleParams(
40
+ this.fromLabel,
41
+ {value: getRoleLabel(item.fromRoleId)},
42
+ {htmlEscaping: true}
43
+ )
40
44
}}
41
45
</list-item >
42
46
<list-item v-if =" item.toRoleId" >
43
47
{{
44
- replaceLocaleParams(this.toLabel, {
45
- value: getRoleLabel(item.toRoleId)
46
- })
48
+ replaceLocaleParams(
49
+ this.toLabel,
50
+ {value: getRoleLabel(item.toRoleId)},
51
+ {htmlEscaping: true}
52
+ )
47
53
}}
48
54
</list-item >
49
55
<list-item
Original file line number Diff line number Diff line change @@ -146,11 +146,20 @@ export default {
146
146
*
147
147
* @param {String } str String to replace params in
148
148
* @param {Object } params Key/value hash of params to replace
149
+ * @param {Object } [options={}]
150
+ * @param {boolean } [options.htmlEscaping=false] - Set to `true` to escape HTML content in param values.
149
151
* @return {String }
150
152
*/
151
- replaceLocaleParams ( str , params ) {
153
+ replaceLocaleParams ( str , params , options = { } ) {
154
+ const { htmlEscaping} = options ;
155
+
152
156
for ( var param in params ) {
153
- let value = params [ param ] ;
157
+ var value = params [ param ] ;
158
+ if ( htmlEscaping ) {
159
+ var p = document . createElement ( 'p' ) ;
160
+ p . innerText = value ;
161
+ value = p . innerHTML ;
162
+ }
154
163
// If a locale object is passed, take the value from the current locale
155
164
if ( value === Object ( value ) ) {
156
165
value = this . localize ( value ) ;
You can’t perform that action at this time.
0 commit comments