Skip to content

Commit bf24ca2

Browse files
committed
[FIX] sap/base/security/sanitizeHTML: Add support for modern CSS display values
Extended CSS display property allowlist to include modern layout values (flex, inline-flex, grid, inline-grid, flow-root, contents) and global CSS keywords (initial, revert, revert-layer, unset). SNOW: DINC0606162 Change-Id: I749683913dae11fb0b68ae67a81d48c64572763f CR-Id: 002075125800003918632025
1 parent dedbd66 commit bf24ca2

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

src/sap.ui.core/src/sap/ui/core/.library

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@
266266
<copyright>2009-2014 Stuart Knightley, David Duponchel, Franz Buchinger, António Afonso</copyright>
267267
<pattern>sap/ui/thirdparty/jszip.js</pattern>
268268
</lib>
269-
<lib name="caja" displayName="Google-Caja JS HTML Sanitizer" npmName="n/a" version="Build 4884" hash="334c6e85c052f2d23405fb7ecec5de67" homepage="http://code.google.com/p/google-caja/wiki/JsHtmlSanitizer" id="73554900106100001928">
269+
<lib name="caja" displayName="Google-Caja JS HTML Sanitizer" npmName="n/a" version="Build 4884" hash="098bd372b10fd5938a88bdccd8dfbeab" homepage="http://code.google.com/p/google-caja/wiki/JsHtmlSanitizer" id="73554900106100001928">
270270
<license url="http://www.apache.org/licenses/LICENSE-2.0" type="Apache-2.0" />
271271
<copyright>Google Inc.</copyright>
272272
<pattern>sap/ui/thirdparty/caja-html-sanitizer.js</pattern>

src/sap.ui.core/src/sap/ui/thirdparty/caja-html-sanitizer.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,11 @@ var cssSchema = (function () {
118118
'inset' ], [ 'invert' ], [ 'justify' ], [ 'local' ], [ 'medium' ], [
119119
'mix' ], [ 'none' ], [ 'normal' ], [ 'once' ], [ 'repeat' ], [ 'scroll'
120120
], [ 'separate' ], [ 'small-caps' ], [ 'spell-out' ], [ 'transparent' ],
121-
[ 'visible' ] ];
121+
[ 'visible' ],
122+
// ##### BEGIN: MODIFIED BY SAP
123+
[ 'flex', 'inline-flex', 'grid', 'inline-grid', 'flow-root', 'contents' ], [ 'initial', 'revert', 'revert-layer', 'unset' ]
124+
// ##### END: MODIFIED BY SAP
125+
];
122126
return {
123127
'-moz-border-radius': {
124128
'cssExtra': c[ 0 ],
@@ -440,7 +444,9 @@ var cssSchema = (function () {
440444
},
441445
'display': {
442446
'cssPropBits': 32,
443-
'cssLitGroup': [ L[ 2 ], L[ 47 ], L[ 54 ] ]
447+
// ##### BEGIN: MODIFIED BY SAP
448+
'cssLitGroup': [ L[ 2 ], L[ 47 ], L[ 54 ], L[ 64 ], L[ 65 ] ]
449+
// ##### END: MODIFIED BY SAP
444450
},
445451
'elevation': {
446452
'cssPropBits': 5,

src/sap.ui.core/test/sap/ui/core/qunit/base/security/sanitizeHTML.qunit.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ sap.ui.define([
104104
"a CSS Font Level 4 value (451) is not accepted");
105105
});
106106

107+
QUnit.test("Validate CSS display value", function(assert) {
108+
var input1 = '<div style="display: flex ; width: 100px ; background-color: aqua">HELLO</div>';
109+
assert.equal(sanitizeHTML(input1), input1, "display:flex is preserved");
110+
111+
var input2 = '<div style="display: inline-flex ; width: 100px ; background-color: aqua">HELLO</div>';
112+
assert.equal(sanitizeHTML(input2), input2, "display:inline-flex is preserved");
113+
114+
var input3 = '<div style="display: inline flow-root ; width: 100px ; background-color: aqua">HELLO</div>';
115+
assert.equal(sanitizeHTML(input3), input3, "display:inline flow-root is preserved");
116+
});
117+
107118
QUnit.module("Sanitizer Performance", {
108119
before: function(assert) {
109120
// add a custom assertion "lower than"
@@ -175,4 +186,4 @@ sap.ui.define([
175186
});
176187
});
177188

178-
});
189+
});

0 commit comments

Comments
 (0)