<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[46235] trunk: KSES: Add support for modern layout techniques in `style` attribute.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/46235">46235</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/46235","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>peterwilsoncc</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2019-09-22 22:16:19 +0000 (Sun, 22 Sep 2019)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>KSES: Add support for modern layout techniques in `style` attribute.

Adds support for `flex`, `grid` and `column` layout techniques to the list of CSS attributes considered safe for inline CSS. The `\` character and CSS functions, eg `minmax()` are not yet supported.

Extends support of `border` properties to include `border-radius` and individual `background` properties to include all those implicitly supported by the shorthand attribute.

Props mrahmadawais, marybaum, birgire, peterwilsoncc, azaozz.
Fixes <a href="https://core.trac.wordpress.org/ticket/37248">#37248</a>.
See <a href="https://core.trac.wordpress.org/ticket/47367">#47367</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesksesphp">trunk/src/wp-includes/kses.php</a></li>
<li><a href="#trunktestsphpunittestsksesphp">trunk/tests/phpunit/tests/kses.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesksesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/kses.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/kses.php    2019-09-22 21:58:06 UTC (rev 46234)
+++ trunk/src/wp-includes/kses.php      2019-09-22 22:16:19 UTC (rev 46235)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2071,7 +2071,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 5.0.0 Added support for `background-image`.
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 5.1.0 Added support for `text-transform`.
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 5.2.0 Added support for `background-position` and `grid-template-columns`
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.3.0 Added support for `flex`, `flex-grow`, `flex-shrink`, and `flex-basis`.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 5.3.0 Added support for `grid`, `flex` and `column` layout properties.
+        *              Extend `background-*` support of individual properties.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param string[] $attr Array of allowed CSS attributes.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2082,8 +2083,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'background-color',
</span><span class="cx" style="display: block; padding: 0 10px">                        'background-image',
</span><span class="cx" style="display: block; padding: 0 10px">                        'background-position',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        'background-size',
+                       'background-attachment',
+                       'background-blend-mode',
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        'border',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        'border-radius',
</ins><span class="cx" style="display: block; padding: 0 10px">                         'border-width',
</span><span class="cx" style="display: block; padding: 0 10px">                        'border-color',
</span><span class="cx" style="display: block; padding: 0 10px">                        'border-style',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2108,6 +2113,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'border-collapse',
</span><span class="cx" style="display: block; padding: 0 10px">                        'caption-side',
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        'columns',
+                       'column-count',
+                       'column-fill',
+                       'column-gap',
+                       'column-rule',
+                       'column-span',
+                       'column-width',
+
</ins><span class="cx" style="display: block; padding: 0 10px">                         'color',
</span><span class="cx" style="display: block; padding: 0 10px">                        'font',
</span><span class="cx" style="display: block; padding: 0 10px">                        'font-family',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2143,10 +2156,31 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'padding-top',
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        'flex',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        'flex-basis',
+                       'flex-direction',
+                       'flex-flow',
</ins><span class="cx" style="display: block; padding: 0 10px">                         'flex-grow',
</span><span class="cx" style="display: block; padding: 0 10px">                        'flex-shrink',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'flex-basis',
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        'grid-template-columns',
+                       'grid-auto-columns',
+                       'grid-column-start',
+                       'grid-column-end',
+                       'grid-column-gap',
+                       'grid-template-rows',
+                       'grid-auto-rows',
+                       'grid-row-start',
+                       'grid-row-end',
+                       'grid-row-gap',
+                       'grid-gap',
+
+                       'justify-content',
+                       'justify-items',
+                       'justify-self',
+                       'align-content',
+                       'align-items',
+                       'align-self',
+
</ins><span class="cx" style="display: block; padding: 0 10px">                         'clear',
</span><span class="cx" style="display: block; padding: 0 10px">                        'cursor',
</span><span class="cx" style="display: block; padding: 0 10px">                        'direction',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2154,7 +2188,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'overflow',
</span><span class="cx" style="display: block; padding: 0 10px">                        'vertical-align',
</span><span class="cx" style="display: block; padding: 0 10px">                        'list-style-type',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'grid-template-columns',
</del><span class="cx" style="display: block; padding: 0 10px">                 )
</span><span class="cx" style="display: block; padding: 0 10px">        );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre></div>
<a id="trunktestsphpunittestsksesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/kses.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/kses.php        2019-09-22 21:58:06 UTC (rev 46234)
+++ trunk/tests/phpunit/tests/kses.php  2019-09-22 22:16:19 UTC (rev 46235)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -839,11 +839,45 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                'css'      => 'background: green url("foo.jpg") no-repeat fixed center',
</span><span class="cx" style="display: block; padding: 0 10px">                                'expected' => 'background: green url("foo.jpg") no-repeat fixed center',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        // Additional background attributes introduced in 5.3.
+                       array(
+                               'css'      => 'background-size: cover;background-size: 200px 100px;background-attachment: local, scroll;background-blend-mode: hard-light',
+                               'expected' => 'background-size: cover;background-size: 200px 100px;background-attachment: local, scroll;background-blend-mode: hard-light',
+                       ),
+                       // `border-radius` attribute introduced in 5.3.
+                       array(
+                               'css'      => 'border-radius: 10% 30% 50% 70%;border-radius: 30px',
+                               'expected' => 'border-radius: 10% 30% 50% 70%;border-radius: 30px',
+                       ),
</ins><span class="cx" style="display: block; padding: 0 10px">                         // `flex` and related attributes introduced in 5.3.
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'css'      => 'flex: 0 1 auto;flex-basis: 75%;flex-shrink: 0;flex-grow: 1',
-                               'expected' => 'flex: 0 1 auto;flex-basis: 75%;flex-shrink: 0;flex-grow: 1',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'css'      => 'flex: 0 1 auto;flex-basis: 75%;flex-direction: row-reverse;flex-flow: row-reverse nowrap;flex-grow: 2;flex-shrink: 1',
+                               'expected' => 'flex: 0 1 auto;flex-basis: 75%;flex-direction: row-reverse;flex-flow: row-reverse nowrap;flex-grow: 2;flex-shrink: 1',
</ins><span class="cx" style="display: block; padding: 0 10px">                         ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        // `grid` and related attributes introduced in 5.3.
+                       array(
+                               'css'      => 'grid-template-columns: 1fr 60px;grid-auto-columns: min-content;grid-column-start: span 2;grid-column-end: -1;grid-column-gap: 10%;grid-gap: 10px 20px',
+                               'expected' => 'grid-template-columns: 1fr 60px;grid-auto-columns: min-content;grid-column-start: span 2;grid-column-end: -1;grid-column-gap: 10%;grid-gap: 10px 20px',
+                       ),
+                       array(
+                               'css'      => 'grid-template-rows: 40px 4em 40px;grid-auto-rows: min-content;grid-row-start: -1;grid-row-end: 3;grid-row-gap: 1em',
+                               'expected' => 'grid-template-rows: 40px 4em 40px;grid-auto-rows: min-content;grid-row-start: -1;grid-row-end: 3;grid-row-gap: 1em',
+                       ),
+                       // `grid` does not yet support functions or `\`.
+                       array(
+                               'css'      => 'grid-template-columns: repeat(2, 50px 1fr);grid-template: 1em / 20% 20px 1fr',
+                               'expected' => '',
+                       ),
+                       // `flex` and `grid` alignments introduced in 5.3.
+                       array(
+                               'css'      => 'align-content: space-between;align-items: start;align-self: center;justify-items: center;justify-content: space-between;justify-self: end',
+                               'expected' => 'align-content: space-between;align-items: start;align-self: center;justify-items: center;justify-content: space-between;justify-self: end',
+                       ),
+                       // `columns` and related attributes introduced in 5.3.
+                       array(
+                               'css'      => 'columns: 6rem auto;column-count: 4;column-fill: balance;column-gap: 9px;column-rule: thick inset blue;column-span: none;column-width: 120px',
+                               'expected' => 'columns: 6rem auto;column-count: 4;column-fill: balance;column-gap: 9px;column-rule: thick inset blue;column-span: none;column-width: 120px',
+                       ),
</ins><span class="cx" style="display: block; padding: 0 10px">                 );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre>
</div>
</div>

</body>
</html>