diff --git a/include/thirdparty/wp/kses.php b/include/thirdparty/wp/kses.php index 2d6d796..0c5a04a 100644 --- a/include/thirdparty/wp/kses.php +++ b/include/thirdparty/wp/kses.php @@ -1,4 +1,5 @@ array(), - 'a' => array( - 'href' => true, - 'rel' => true, - 'rev' => true, - 'name' => true, - 'target' => true, + 'address' => array(), + 'a' => array( + 'href' => true, + 'rel' => true, + 'rev' => true, + 'name' => true, + 'target' => true, + 'download' => array( + 'valueless' => 'y', + ), ), - 'abbr' => array(), - 'acronym' => array(), - 'area' => array( - 'alt' => true, + 'abbr' => array(), + 'acronym' => array(), + 'area' => array( + 'alt' => true, 'coords' => true, - 'href' => true, + 'href' => true, 'nohref' => true, - 'shape' => true, + 'shape' => true, 'target' => true, ), - 'article' => array( - 'align' => true, - 'dir' => true, - 'lang' => true, + 'article' => array( + 'align' => true, + 'dir' => true, + 'lang' => true, 'xml:lang' => true, ), - 'aside' => array( - 'align' => true, - 'dir' => true, - 'lang' => true, + 'aside' => array( + 'align' => true, + 'dir' => true, + 'lang' => true, 'xml:lang' => true, ), - 'b' => array(), - 'big' => array(), + 'audio' => array( + 'autoplay' => true, + 'controls' => true, + 'loop' => true, + 'muted' => true, + 'preload' => true, + 'src' => true, + ), + 'b' => array(), + 'bdo' => array( + 'dir' => true, + ), + 'big' => array(), 'blockquote' => array( - 'cite' => true, - 'lang' => true, + 'cite' => true, + 'lang' => true, 'xml:lang' => true, ), - 'br' => array(), - 'button' => array( + 'br' => array(), + 'button' => array( 'disabled' => true, - 'name' => true, - 'type' => true, - 'value' => true, + 'name' => true, + 'type' => true, + 'value' => true, ), - 'caption' => array( + 'caption' => array( 'align' => true, ), - 'cite' => array( - 'dir' => true, + 'cite' => array( + 'dir' => true, 'lang' => true, ), - 'code' => array(), - 'col' => array( - 'align' => true, - 'char' => true, + 'code' => array(), + 'col' => array( + 'align' => true, + 'char' => true, 'charoff' => true, - 'span' => true, - 'dir' => true, - 'valign' => true, - 'width' => true, + 'span' => true, + 'dir' => true, + 'valign' => true, + 'width' => true, ), - 'del' => array( + 'colgroup' => array( + 'align' => true, + 'char' => true, + 'charoff' => true, + 'span' => true, + 'valign' => true, + 'width' => true, + ), + 'del' => array( 'datetime' => true, ), - 'dd' => array(), - 'details' => array( - 'align' => true, - 'dir' => true, - 'lang' => true, - 'open' => true, + 'dd' => array(), + 'dfn' => array(), + 'details' => array( + 'align' => true, + 'dir' => true, + 'lang' => true, + 'open' => true, 'xml:lang' => true, ), - 'div' => array( - 'align' => true, - 'dir' => true, - 'lang' => true, + 'div' => array( + 'align' => true, + 'dir' => true, + 'lang' => true, 'xml:lang' => true, - 'style' => true, ), - 'dl' => array(), - 'dt' => array(), - 'em' => array(), - 'fieldset' => array(), - 'figure' => array( - 'align' => true, - 'dir' => true, - 'lang' => true, + 'dl' => array(), + 'dt' => array(), + 'em' => array(), + 'fieldset' => array(), + 'figure' => array( + 'align' => true, + 'dir' => true, + 'lang' => true, 'xml:lang' => true, ), 'figcaption' => array( - 'align' => true, - 'dir' => true, - 'lang' => true, + 'align' => true, + 'dir' => true, + 'lang' => true, 'xml:lang' => true, ), - 'font' => array( + 'font' => array( 'color' => true, - 'face' => true, - 'size' => true, + 'face' => true, + 'size' => true, ), - 'footer' => array( - 'align' => true, - 'dir' => true, - 'lang' => true, + 'footer' => array( + 'align' => true, + 'dir' => true, + 'lang' => true, 'xml:lang' => true, ), - 'form' => array( - 'action' => true, - 'accept' => true, - 'accept-charset' => true, - 'enctype' => true, - 'method' => true, - 'name' => true, - 'target' => true, - ), - 'h1' => array( + 'h1' => array( 'align' => true, ), - 'h2' => array( + 'h2' => array( 'align' => true, ), - 'h3' => array( + 'h3' => array( 'align' => true, ), - 'h4' => array( + 'h4' => array( 'align' => true, ), - 'h5' => array( + 'h5' => array( 'align' => true, ), - 'h6' => array( + 'h6' => array( 'align' => true, ), - 'header' => array( - 'align' => true, - 'dir' => true, - 'lang' => true, + 'header' => array( + 'align' => true, + 'dir' => true, + 'lang' => true, 'xml:lang' => true, ), - 'hgroup' => array( - 'align' => true, - 'dir' => true, - 'lang' => true, + 'hgroup' => array( + 'align' => true, + 'dir' => true, + 'lang' => true, 'xml:lang' => true, ), - 'hr' => array( - 'align' => true, + 'hr' => array( + 'align' => true, 'noshade' => true, - 'size' => true, - 'width' => true, + 'size' => true, + 'width' => true, ), - 'i' => array(), - 'img' => array( - 'alt' => true, - 'align' => true, - 'border' => true, - 'height' => true, - 'hspace' => true, + 'i' => array(), + 'img' => array( + 'alt' => true, + 'align' => true, + 'border' => true, + 'height' => true, + 'hspace' => true, + 'loading' => true, 'longdesc' => true, - 'vspace' => true, - 'src' => true, - 'usemap' => true, - 'width' => true, + 'vspace' => true, + 'src' => true, + 'usemap' => true, + 'width' => true, ), - 'ins' => array( + 'ins' => array( 'datetime' => true, - 'cite' => true, + 'cite' => true, ), - 'kbd' => array(), - 'label' => array( + 'kbd' => array(), + 'label' => array( 'for' => true, ), - 'legend' => array( + 'legend' => array( 'align' => true, ), - 'li' => array( + 'li' => array( 'align' => true, + 'value' => true, ), - 'map' => array( + 'main' => array( + 'align' => true, + 'dir' => true, + 'lang' => true, + 'xml:lang' => true, + ), + 'map' => array( 'name' => true, ), - 'menu' => array( + 'mark' => array(), + 'menu' => array( 'type' => true, ), - 'nav' => array( - 'align' => true, - 'dir' => true, - 'lang' => true, + 'nav' => array( + 'align' => true, + 'dir' => true, + 'lang' => true, 'xml:lang' => true, ), - 'p' => array( - 'align' => true, - 'dir' => true, - 'lang' => true, + 'p' => array( + 'align' => true, + 'dir' => true, + 'lang' => true, 'xml:lang' => true, ), - 'pre' => array( + 'pre' => array( 'width' => true, ), - 'q' => array( + 'q' => array( 'cite' => true, ), - 's' => array(), - 'span' => array( - 'dir' => true, - 'align' => true, - 'lang' => true, + 's' => array(), + 'samp' => array(), + 'span' => array( + 'dir' => true, + 'align' => true, + 'lang' => true, 'xml:lang' => true, ), - 'section' => array( - 'align' => true, - 'dir' => true, - 'lang' => true, + 'section' => array( + 'align' => true, + 'dir' => true, + 'lang' => true, 'xml:lang' => true, ), - 'small' => array(), - 'strike' => array(), - 'strong' => array(), - 'sub' => array(), - 'summary' => array( - 'align' => true, - 'dir' => true, - 'lang' => true, + 'small' => array(), + 'strike' => array(), + 'strong' => array(), + 'sub' => array(), + 'summary' => array( + 'align' => true, + 'dir' => true, + 'lang' => true, 'xml:lang' => true, ), - 'sup' => array(), - 'table' => array( - 'align' => true, - 'bgcolor' => true, - 'border' => true, + 'sup' => array(), + 'table' => array( + 'align' => true, + 'bgcolor' => true, + 'border' => true, 'cellpadding' => true, 'cellspacing' => true, - 'dir' => true, - 'rules' => true, - 'summary' => true, - 'width' => true, + 'dir' => true, + 'rules' => true, + 'summary' => true, + 'width' => true, ), - 'tbody' => array( - 'align' => true, - 'char' => true, + 'tbody' => array( + 'align' => true, + 'char' => true, 'charoff' => true, - 'valign' => true, + 'valign' => true, ), - 'td' => array( - 'abbr' => true, - 'align' => true, - 'axis' => true, + 'td' => array( + 'abbr' => true, + 'align' => true, + 'axis' => true, 'bgcolor' => true, - 'char' => true, + 'char' => true, 'charoff' => true, 'colspan' => true, - 'dir' => true, + 'dir' => true, 'headers' => true, - 'height' => true, - 'nowrap' => true, + 'height' => true, + 'nowrap' => true, 'rowspan' => true, - 'scope' => true, - 'valign' => true, - 'width' => true, + 'scope' => true, + 'valign' => true, + 'width' => true, ), - 'textarea' => array( - 'cols' => true, - 'rows' => true, + 'textarea' => array( + 'cols' => true, + 'rows' => true, 'disabled' => true, - 'name' => true, + 'name' => true, 'readonly' => true, ), - 'tfoot' => array( - 'align' => true, - 'char' => true, + 'tfoot' => array( + 'align' => true, + 'char' => true, 'charoff' => true, - 'valign' => true, + 'valign' => true, ), - 'th' => array( - 'abbr' => true, - 'align' => true, - 'axis' => true, + 'th' => array( + 'abbr' => true, + 'align' => true, + 'axis' => true, 'bgcolor' => true, - 'char' => true, + 'char' => true, 'charoff' => true, 'colspan' => true, 'headers' => true, - 'height' => true, - 'nowrap' => true, + 'height' => true, + 'nowrap' => true, 'rowspan' => true, - 'scope' => true, - 'valign' => true, - 'width' => true, + 'scope' => true, + 'valign' => true, + 'width' => true, ), - 'thead' => array( - 'align' => true, - 'char' => true, + 'thead' => array( + 'align' => true, + 'char' => true, 'charoff' => true, - 'valign' => true, + 'valign' => true, ), - 'title' => array(), - 'tr' => array( - 'align' => true, + 'title' => array(), + 'tr' => array( + 'align' => true, 'bgcolor' => true, - 'char' => true, + 'char' => true, 'charoff' => true, - 'valign' => true, + 'valign' => true, ), - 'tt' => array(), - 'u' => array(), - 'ul' => array( + 'track' => array( + 'default' => true, + 'kind' => true, + 'label' => true, + 'src' => true, + 'srclang' => true, + ), + 'tt' => array(), + 'u' => array(), + 'ul' => array( 'type' => true, ), - 'ol' => array( - 'start' => true, - 'type' => true, + 'ol' => array( + 'start' => true, + 'type' => true, + 'reversed' => true, + ), + 'var' => array(), + 'video' => array( + 'autoplay' => true, + 'controls' => true, + 'height' => true, + 'loop' => true, + 'muted' => true, + 'playsinline' => true, + 'poster' => true, + 'preload' => true, + 'src' => true, + 'width' => true, ), - 'var' => array(), ); + /** + * @var array[] $allowedtags Array of KSES allowed HTML elements. + * @since 1.0.0 + */ + $allowedtags = array( + 'a' => array( + 'href' => true, + 'title' => true, + ), + 'abbr' => array( + 'title' => true, + ), + 'acronym' => array( + 'title' => true, + ), + 'b' => array(), + 'blockquote' => array( + 'cite' => true, + ), + 'cite' => array(), + 'code' => array(), + 'del' => array( + 'datetime' => true, + ), + 'em' => array(), + 'i' => array(), + 'q' => array( + 'cite' => true, + ), + 's' => array(), + 'strike' => array(), + 'strong' => array(), + ); + + /** + * @var string[] $allowedentitynames Array of KSES allowed HTML entitity names. + * @since 1.0.0 + */ $allowedentitynames = array( - 'nbsp', 'iexcl', 'cent', 'pound', 'curren', 'yen', - 'brvbar', 'sect', 'uml', 'copy', 'ordf', 'laquo', - 'not', 'shy', 'reg', 'macr', 'deg', 'plusmn', - 'acute', 'micro', 'para', 'middot', 'cedil', 'ordm', - 'raquo', 'iquest', 'Agrave', 'Aacute', 'Acirc', 'Atilde', - 'Auml', 'Aring', 'AElig', 'Ccedil', 'Egrave', 'Eacute', - 'Ecirc', 'Euml', 'Igrave', 'Iacute', 'Icirc', 'Iuml', - 'ETH', 'Ntilde', 'Ograve', 'Oacute', 'Ocirc', 'Otilde', - 'Ouml', 'times', 'Oslash', 'Ugrave', 'Uacute', 'Ucirc', - 'Uuml', 'Yacute', 'THORN', 'szlig', 'agrave', 'aacute', - 'acirc', 'atilde', 'auml', 'aring', 'aelig', 'ccedil', - 'egrave', 'eacute', 'ecirc', 'euml', 'igrave', 'iacute', - 'icirc', 'iuml', 'eth', 'ntilde', 'ograve', 'oacute', - 'ocirc', 'otilde', 'ouml', 'divide', 'oslash', 'ugrave', - 'uacute', 'ucirc', 'uuml', 'yacute', 'thorn', 'yuml', - 'quot', 'amp', 'lt', 'gt', 'apos', 'OElig', - 'oelig', 'Scaron', 'scaron', 'Yuml', 'circ', 'tilde', - 'ensp', 'emsp', 'thinsp', 'zwnj', 'zwj', 'lrm', - 'rlm', 'ndash', 'mdash', 'lsquo', 'rsquo', 'sbquo', - 'ldquo', 'rdquo', 'bdquo', 'dagger', 'Dagger', 'permil', - 'lsaquo', 'rsaquo', 'euro', 'fnof', 'Alpha', 'Beta', - 'Gamma', 'Delta', 'Epsilon', 'Zeta', 'Eta', 'Theta', - 'Iota', 'Kappa', 'Lambda', 'Mu', 'Nu', 'Xi', - 'Omicron', 'Pi', 'Rho', 'Sigma', 'Tau', 'Upsilon', - 'Phi', 'Chi', 'Psi', 'Omega', 'alpha', 'beta', - 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', - 'iota', 'kappa', 'lambda', 'mu', 'nu', 'xi', - 'omicron', 'pi', 'rho', 'sigmaf', 'sigma', 'tau', - 'upsilon', 'phi', 'chi', 'psi', 'omega', 'thetasym', - 'upsih', 'piv', 'bull', 'hellip', 'prime', 'Prime', - 'oline', 'frasl', 'weierp', 'image', 'real', 'trade', - 'alefsym', 'larr', 'uarr', 'rarr', 'darr', 'harr', - 'crarr', 'lArr', 'uArr', 'rArr', 'dArr', 'hArr', - 'forall', 'part', 'exist', 'empty', 'nabla', 'isin', - 'notin', 'ni', 'prod', 'sum', 'minus', 'lowast', - 'radic', 'prop', 'infin', 'ang', 'and', 'or', - 'cap', 'cup', 'int', 'sim', 'cong', 'asymp', - 'ne', 'equiv', 'le', 'ge', 'sub', 'sup', - 'nsub', 'sube', 'supe', 'oplus', 'otimes', 'perp', - 'sdot', 'lceil', 'rceil', 'lfloor', 'rfloor', 'lang', - 'rang', 'loz', 'spades', 'clubs', 'hearts', 'diams', + 'nbsp', + 'iexcl', + 'cent', + 'pound', + 'curren', + 'yen', + 'brvbar', + 'sect', + 'uml', + 'copy', + 'ordf', + 'laquo', + 'not', + 'shy', + 'reg', + 'macr', + 'deg', + 'plusmn', + 'acute', + 'micro', + 'para', + 'middot', + 'cedil', + 'ordm', + 'raquo', + 'iquest', + 'Agrave', + 'Aacute', + 'Acirc', + 'Atilde', + 'Auml', + 'Aring', + 'AElig', + 'Ccedil', + 'Egrave', + 'Eacute', + 'Ecirc', + 'Euml', + 'Igrave', + 'Iacute', + 'Icirc', + 'Iuml', + 'ETH', + 'Ntilde', + 'Ograve', + 'Oacute', + 'Ocirc', + 'Otilde', + 'Ouml', + 'times', + 'Oslash', + 'Ugrave', + 'Uacute', + 'Ucirc', + 'Uuml', + 'Yacute', + 'THORN', + 'szlig', + 'agrave', + 'aacute', + 'acirc', + 'atilde', + 'auml', + 'aring', + 'aelig', + 'ccedil', + 'egrave', + 'eacute', + 'ecirc', + 'euml', + 'igrave', + 'iacute', + 'icirc', + 'iuml', + 'eth', + 'ntilde', + 'ograve', + 'oacute', + 'ocirc', + 'otilde', + 'ouml', + 'divide', + 'oslash', + 'ugrave', + 'uacute', + 'ucirc', + 'uuml', + 'yacute', + 'thorn', + 'yuml', + 'quot', + 'amp', + 'lt', + 'gt', + 'apos', + 'OElig', + 'oelig', + 'Scaron', + 'scaron', + 'Yuml', + 'circ', + 'tilde', + 'ensp', + 'emsp', + 'thinsp', + 'zwnj', + 'zwj', + 'lrm', + 'rlm', + 'ndash', + 'mdash', + 'lsquo', + 'rsquo', + 'sbquo', + 'ldquo', + 'rdquo', + 'bdquo', + 'dagger', + 'Dagger', + 'permil', + 'lsaquo', + 'rsaquo', + 'euro', + 'fnof', + 'Alpha', + 'Beta', + 'Gamma', + 'Delta', + 'Epsilon', + 'Zeta', + 'Eta', + 'Theta', + 'Iota', + 'Kappa', + 'Lambda', + 'Mu', + 'Nu', + 'Xi', + 'Omicron', + 'Pi', + 'Rho', + 'Sigma', + 'Tau', + 'Upsilon', + 'Phi', + 'Chi', + 'Psi', + 'Omega', + 'alpha', + 'beta', + 'gamma', + 'delta', + 'epsilon', + 'zeta', + 'eta', + 'theta', + 'iota', + 'kappa', + 'lambda', + 'mu', + 'nu', + 'xi', + 'omicron', + 'pi', + 'rho', + 'sigmaf', + 'sigma', + 'tau', + 'upsilon', + 'phi', + 'chi', + 'psi', + 'omega', + 'thetasym', + 'upsih', + 'piv', + 'bull', + 'hellip', + 'prime', + 'Prime', + 'oline', + 'frasl', + 'weierp', + 'image', + 'real', + 'trade', + 'alefsym', + 'larr', + 'uarr', + 'rarr', + 'darr', + 'harr', + 'crarr', + 'lArr', + 'uArr', + 'rArr', + 'dArr', + 'hArr', + 'forall', + 'part', + 'exist', + 'empty', + 'nabla', + 'isin', + 'notin', + 'ni', + 'prod', + 'sum', + 'minus', + 'lowast', + 'radic', + 'prop', + 'infin', + 'ang', + 'and', + 'or', + 'cap', + 'cup', + 'int', + 'sim', + 'cong', + 'asymp', + 'ne', + 'equiv', + 'le', + 'ge', + 'sub', + 'sup', + 'nsub', + 'sube', + 'supe', + 'oplus', + 'otimes', + 'perp', + 'sdot', + 'lceil', + 'rceil', + 'lfloor', + 'rfloor', + 'lang', + 'rang', + 'loz', + 'spades', + 'clubs', + 'hearts', + 'diams', + 'sup1', + 'sup2', + 'sup3', + 'frac14', + 'frac12', + 'frac34', + 'there4', ); - $allowedprotocols = array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn' ); - + /** + * @var string[] $allowedxmlentitynames Array of KSES allowed XML entitity names. + * @since 5.5.0 + */ + $allowedxmlnamedentities = array( + 'amp', + 'lt', + 'gt', + 'apos', + 'quot', + ); $allowedposttags = array_map( '_wp_add_global_attributes', $allowedposttags ); - - -/** - * Filters content and keeps only allowable HTML elements. - * - * This function makes sure that only the allowed HTML element names, attribute - * names and attribute values plus only sane HTML entities will occur in - * $string. You have to remove any slashes from PHP's magic quotes before you - * call this function. - * - * The default allowed protocols are 'http', 'https', 'ftp', 'mailto', 'news', - * 'irc', 'gopher', 'nntp', 'feed', 'telnet, 'mms', 'rtsp' and 'svn'. This - * covers all common link protocols, except for 'javascript' which should not - * be allowed for untrusted users. - * - * @since 1.0.0 - * - * @param string $string Content to filter through kses - * @param array $allowed_html List of allowed HTML elements - * @param array $allowed_protocols Optional. Allowed protocol in links. - * @return string Filtered content with only allowed HTML elements - */ -function wp_kses( $string, $allowed_html, $allowed_protocols = array() ) { - global $allowedprotocols; - if ( empty( $allowed_protocols ) ) - $allowed_protocols = $allowedprotocols; - $string = wp_kses_no_null($string); - $string = wp_kses_js_entities($string); - $string = wp_kses_normalize_entities($string); - return wp_kses_split($string, $allowed_html, $allowed_protocols); +} else { + $allowedtags = wp_kses_array_lc( $allowedtags ); + $allowedposttags = wp_kses_array_lc( $allowedposttags ); } - /** - * This function returns kses' version number. + * Filters text content and strips out disallowed HTML. + * + * This function makes sure that only the allowed HTML element names, attribute + * names, attribute values, and HTML entities will occur in the given text string. + * + * This function expects unslashed data. + * + * @see wp_kses_post() for specifically filtering post content and fields. + * @see wp_allowed_protocols() for the default allowed protocols in link URLs. * * @since 1.0.0 * - * @return string KSES Version Number + * @param string $string Text content to filter. + * @param array[]|string $allowed_html An array of allowed HTML elements and attributes, + * or a context name such as 'post'. See wp_kses_allowed_html() + * for the list of accepted context names. + * @param string[] $allowed_protocols Array of allowed URL protocols. + * @return string Filtered content containing only the allowed HTML. + */ +function wp_kses( $string, $allowed_html, $allowed_protocols = array() ) { + if ( empty( $allowed_protocols ) ) { + $allowed_protocols = wp_allowed_protocols(); + } + + $string = wp_kses_no_null( $string, array( 'slash_zero' => 'keep' ) ); + $string = wp_kses_normalize_entities( $string ); + $string = wp_kses_hook( $string, $allowed_html, $allowed_protocols ); + + return wp_kses_split( $string, $allowed_html, $allowed_protocols ); +} + +/** + * Filters one HTML attribute and ensures its value is allowed. + * + * This function can escape data in some situations where `wp_kses()` must strip the whole attribute. + * + * @since 4.2.3 + * + * @param string $string The 'whole' attribute, including name and value. + * @param string $element The HTML element name to which the attribute belongs. + * @return string Filtered attribute. + */ +function wp_kses_one_attr( $string, $element ) { + $uris = wp_kses_uri_attributes(); + $allowed_html = wp_kses_allowed_html( 'post' ); + $allowed_protocols = wp_allowed_protocols(); + $string = wp_kses_no_null( $string, array( 'slash_zero' => 'keep' ) ); + + // Preserve leading and trailing whitespace. + $matches = array(); + preg_match( '/^\s*/', $string, $matches ); + $lead = $matches[0]; + preg_match( '/\s*$/', $string, $matches ); + $trail = $matches[0]; + if ( empty( $trail ) ) { + $string = substr( $string, strlen( $lead ) ); + } else { + $string = substr( $string, strlen( $lead ), -strlen( $trail ) ); + } + + // Parse attribute name and value from input. + $split = preg_split( '/\s*=\s*/', $string, 2 ); + $name = $split[0]; + if ( count( $split ) == 2 ) { + $value = $split[1]; + + // Remove quotes surrounding $value. + // Also guarantee correct quoting in $string for this one attribute. + if ( '' === $value ) { + $quote = ''; + } else { + $quote = $value[0]; + } + if ( '"' === $quote || "'" === $quote ) { + if ( substr( $value, -1 ) != $quote ) { + return ''; + } + $value = substr( $value, 1, -1 ); + } else { + $quote = '"'; + } + + // Sanitize quotes, angle braces, and entities. + $value = esc_attr( $value ); + + // Sanitize URI values. + if ( in_array( strtolower( $name ), $uris, true ) ) { + $value = wp_kses_bad_protocol( $value, $allowed_protocols ); + } + + $string = "$name=$quote$value$quote"; + $vless = 'n'; + } else { + $value = ''; + $vless = 'y'; + } + + // Sanitize attribute by name. + wp_kses_attr_check( $name, $value, $string, $vless, $element, $allowed_html ); + + // Restore whitespace. + return $lead . $string . $trail; +} + +/** + * Returns an array of allowed HTML tags and attributes for a given context. + * + * @since 3.5.0 + * @since 5.0.1 `form` removed as allowable HTML tag. + * + * @global array $allowedposttags + * @global array $allowedtags + * @global array $allowedentitynames + * + * @param string|array $context The context for which to retrieve tags. Allowed values are 'post', + * 'strip', 'data', 'entities', or the name of a field filter such as + * 'pre_user_description'. + * @return array Array of allowed HTML tags and their allowed attributes. + */ +function wp_kses_allowed_html( $context = '' ) { + global $allowedposttags, $allowedtags, $allowedentitynames; + + if ( is_array( $context ) ) { + /** + * Filters the HTML that is allowed for a given context. + * + * @since 3.5.0 + * + * @param array[]|string $context Context to judge allowed tags by. + * @param string $context_type Context name. + */ + return apply_filters( 'wp_kses_allowed_html', $context, 'explicit' ); + } + + switch ( $context ) { + case 'post': + /** This filter is documented in wp-includes/kses.php */ + $tags = apply_filters( 'wp_kses_allowed_html', $allowedposttags, $context ); + + // 5.0.1 removed the `
` tag, allow it if a filter is allowing it's sub-elements `` or `