Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/codepress-admin-columns/classes/Formatter/Collection/Separator.php
+++ b/codepress-admin-columns/classes/Formatter/Collection/Separator.php
@@ -109,8 +109,8 @@
$toggler = $last_set
? sprintf(
'<span class="ac-show-more__divider">|</span><a class="ac-show-more__toggle" data-show-more-toggle data-more="%1$s" data-less="%2$s">%1$s</a>',
- sprintf(__('%s more', 'codepress-admin-columns'), count($last_set)),
- strtolower(__('Hide', 'codepress-admin-columns'))
+ esc_attr(sprintf(__('%s more', 'codepress-admin-columns'), count($last_set))),
+ esc_attr(strtolower(__('Hide', 'codepress-admin-columns')))
)
: '';
--- a/codepress-admin-columns/classes/Formatter/Comment/CommentLink.php
+++ b/codepress-admin-columns/classes/Formatter/Comment/CommentLink.php
@@ -37,7 +37,7 @@
}
return $link
- ? $value->with_value(HelperHtml::create()->link($link, $value->get_value()))
+ ? $value->with_value(HelperHtml::create()->link_html($link, (string)$value->get_value()))
: $value;
}
--- a/codepress-admin-columns/classes/Formatter/ContentTypeLink.php
+++ b/codepress-admin-columns/classes/Formatter/ContentTypeLink.php
@@ -47,7 +47,7 @@
protected function create_link(string $url, string $value): string
{
- return HelperHtml::create()->link($url, $value);
+ return HelperHtml::create()->link_html($url, $value);
}
abstract protected function get_edit_link(Value $value): ?string;
--- a/codepress-admin-columns/classes/Formatter/Date/DateObject.php
+++ b/codepress-admin-columns/classes/Formatter/Date/DateObject.php
@@ -32,11 +32,21 @@
throw ValueNotFoundException::from_id($value->get_id());
}
+ // A format without a time is parsed with the current time filled in
+ if (! $this->has_time()) {
+ $date->setTime(0, 0);
+ }
+
return $value->with_value(
$date
);
}
+ private function has_time(): bool
+ {
+ return (bool)preg_match('/(?<!\\)[aABgGhHisuvU]/', $this->source_format);
+ }
+
/**
* Checks whether a DateTime parsing operation failed due to an invalid date
* (for example: "0000-00-00 00:00:00").
--- a/codepress-admin-columns/classes/Formatter/Date/TimeElement.php
+++ b/codepress-admin-columns/classes/Formatter/Date/TimeElement.php
@@ -0,0 +1,59 @@
+<?php
+
+declare(strict_types=1);
+
+namespace ACFormatterDate;
+
+use ACExceptionValueNotFoundException;
+use ACFormatter;
+use ACTypeValue;
+use DateTime;
+
+final class TimeElement implements Formatter
+{
+ private Formatter $formatter;
+
+ private DateObject $date_object;
+
+ public function __construct(Formatter $formatter, string $source_format)
+ {
+ $this->formatter = $formatter;
+ $this->date_object = new DateObject($source_format);
+ }
+
+ public function format(Value $value): Value
+ {
+ $formatted = $this->formatter->format($value);
+
+ if ('' === (string)$formatted) {
+ return $formatted;
+ }
+
+ // A date formatter may read another input than the source format, its output still stands
+ try {
+ $date = $this->date_object->format($value)->get_value();
+ } catch (ValueNotFoundException $e) {
+ return $formatted;
+ }
+
+ return $formatted->with_value(
+ sprintf(
+ '<time datetime="%s">%s</time>',
+ esc_attr($this->get_datetime_attribute($date)),
+ (string)$formatted
+ )
+ );
+ }
+
+ private function get_datetime_attribute(DateTime $date): string
+ {
+ // Date fields reach this as midnight, often through a timestamp
+ if ('00:00:00' === $date->format('H:i:s')) {
+ return $date->format('Y-m-d');
+ }
+
+ // Stored dates are the site's clock time, the attribute needs its offset
+ return (new DateTime($date->format('Y-m-d H:i:s'), wp_timezone()))->format(DATE_ATOM);
+ }
+
+}
--- a/codepress-admin-columns/classes/Formatter/Linkable.php
+++ b/codepress-admin-columns/classes/Formatter/Linkable.php
@@ -28,30 +28,32 @@
$url = $value->get_value();
if (filter_var($url, FILTER_VALIDATE_URL) && preg_match('/[^w.-]/', $url)) {
- $link_label = $this->get_formatted_label($url);
-
- return $value->with_value(HelperHtml::create()->link($url, $link_label, ['target' => $this->target]));
+ return $value->with_value($this->create_link($url, $url));
}
if (filter_var($url, FILTER_VALIDATE_EMAIL)) {
- $link_label = $this->get_formatted_label($url);
- $mailto_link = 'mailto:' . $url;
-
- return $value->with_value(HelperHtml::create()->link($mailto_link, $link_label, ['target' => $this->target]));
+ return $value->with_value($this->create_link('mailto:' . $url, $url));
}
return $value;
}
- private function get_formatted_label(string $url): string
+ private function create_link(string $href, string $url): string
{
- $link_label = $this->custom_label ?: $url;
+ $attributes = ['target' => $this->target];
- if ($this->strip_protocol) {
- $link_label = urldecode(str_replace(['http://', 'https://'], '', $link_label));
+ if ($this->custom_label) {
+ return HelperHtml::create()->link_html($href, $this->custom_label, $attributes);
}
- return $link_label;
+ return HelperHtml::create()->link($href, $this->get_url_label($url), $attributes);
+ }
+
+ private function get_url_label(string $url): string
+ {
+ return $this->strip_protocol
+ ? urldecode(str_replace(['http://', 'https://'], '', $url))
+ : $url;
}
}
--- a/codepress-admin-columns/classes/Formatter/Media/FileLinkToUrl.php
+++ b/codepress-admin-columns/classes/Formatter/Media/FileLinkToUrl.php
@@ -19,7 +19,7 @@
}
return $value->with_value(
- HelperHtml::create()->link(
+ HelperHtml::create()->link_html(
$url,
(string)$value
)
--- a/codepress-admin-columns/classes/Formatter/MenuLink.php
+++ b/codepress-admin-columns/classes/Formatter/MenuLink.php
@@ -13,9 +13,9 @@
public function format(Value $value): Value
{
return $value->with_value(
- HelperHtml::create()->link(
+ HelperHtml::create()->link_html(
add_query_arg(['menu' => $value->get_id()], admin_url('nav-menus.php')),
- $value->get_value()
+ (string)$value->get_value()
)
);
}
--- a/codepress-admin-columns/classes/Formatter/Post/CommentsForPostLink.php
+++ b/codepress-admin-columns/classes/Formatter/Post/CommentsForPostLink.php
@@ -26,7 +26,7 @@
throw ValueNotFoundException::from_id($value->get_id());
}
- $link = HelperHtml::create()->link(
+ $link = HelperHtml::create()->link_html(
add_query_arg(
[
'p' => $value->get_id(),
--- a/codepress-admin-columns/classes/Formatter/Post/PostLink.php
+++ b/codepress-admin-columns/classes/Formatter/Post/PostLink.php
@@ -51,7 +51,7 @@
}
return $link
- ? $value->with_value(HelperHtml::create()->link($link, (string)$value))
+ ? $value->with_value(HelperHtml::create()->link_html($link, (string)$value))
: $value;
}
--- a/codepress-admin-columns/classes/Formatter/Term/TermLink.php
+++ b/codepress-admin-columns/classes/Formatter/Term/TermLink.php
@@ -52,7 +52,7 @@
}
return $link && is_string($link)
- ? $value->with_value(HelperHtml::create()->link($link, (string)$value))
+ ? $value->with_value(HelperHtml::create()->link_html($link, (string)$value))
: $value;
}
--- a/codepress-admin-columns/classes/Formatter/User/UserLink.php
+++ b/codepress-admin-columns/classes/Formatter/User/UserLink.php
@@ -69,7 +69,7 @@
}
return $link
- ? $value->with_value(HelperHtml::create()->link($link, (string)$value))
+ ? $value->with_value(HelperHtml::create()->link_html($link, (string)$value))
: $value;
}
--- a/codepress-admin-columns/classes/Helper/Html.php
+++ b/codepress-admin-columns/classes/Helper/Html.php
@@ -29,20 +29,28 @@
public function link(string $url, ?string $label = null, array $attributes = []): string
{
- if (! $url) {
- return $label ?? '';
- }
-
if (null === $label) {
$label = urldecode($url);
}
- if (! $label) {
+ return $this->link_html($url, esc_html($label), $attributes);
+ }
+
+ /**
+ * A label with HTML is rendered as is: only pass HTML that is already safe to output.
+ */
+ public function link_html(string $url, string $html, array $attributes = []): string
+ {
+ if (! $url) {
+ return $html;
+ }
+
+ if (! $html) {
return '';
}
- if (! $this->contains_html($label)) {
- $label = esc_html($label);
+ if ($html === strip_tags($html)) {
+ $html = esc_html($html);
}
$tooltip = null;
@@ -59,7 +67,7 @@
$link = new Link(
$url,
- $label,
+ $html,
$this->filter_attributes($attributes),
$protocols
);
@@ -147,11 +155,6 @@
return $hrefs;
}
- private function contains_html(string $string): bool
- {
- return $string && $string !== strip_tags($string);
- }
-
public function divided(array $array): string
{
$array = Arrays::create()->filter($array);
--- a/codepress-admin-columns/classes/Sanitize/Kses.php
+++ b/codepress-admin-columns/classes/Sanitize/Kses.php
@@ -16,6 +16,9 @@
$html = wp_kses_allowed_html('post');
$html['a']['download'] = true;
+ $html['time'] = [
+ 'datetime' => true,
+ ];
$html['iframe'] = [
'src' => true,
'height' => true,
--- a/codepress-admin-columns/classes/Setting/ComponentFactory/DateFormat.php
+++ b/codepress-admin-columns/classes/Setting/ComponentFactory/DateFormat.php
@@ -110,10 +110,12 @@
protected function add_formatters(Config $config, FormatterCollection $formatters): void
{
+ $date_formatter = $this->get_date_formatter(
+ (string)$config->get('date_format') ?: $this->get_default_option()
+ );
+
$formatters->add(
- $this->get_date_formatter(
- (string)$config->get('date_format') ?: $this->get_default_option()
- )
+ new FormatterDateTimeElement($date_formatter, $this->source_format)
);
}
--- a/codepress-admin-columns/classes/Table/InlineStyle/ColumnSize.php
+++ b/codepress-admin-columns/classes/Table/InlineStyle/ColumnSize.php
@@ -39,7 +39,12 @@
$list_width = $this->list_storage->get($column);
$user_width = $this->user_storage->get($list_screen->get_id(), $column_id);
- $html .= $this->render_base_style($table_id, $column_id, $list_width);
+ // Without a width there is nothing to size the column to. Printing the
+ // rule anyway would force auto !important and override core and
+ // third-party column widths.
+ if ($list_width || $user_width) {
+ $html .= $this->render_base_style($table_id, $column_id, $list_width);
+ }
if ($user_width) {
$html .= $this->render_user_style($table_id, $column_id, $user_width);
--- a/codepress-admin-columns/codepress-admin-columns.php
+++ b/codepress-admin-columns/codepress-admin-columns.php
@@ -4,7 +4,7 @@
/*
Plugin Name: Admin Columns
-Version: 7.1.8
+Version: 7.1.9
Description: Add, reorder, and customize columns in your WordPress admin table for any post type, users, and media - no code required.
Author: AdminColumns.com
Author URI: https://www.admincolumns.com
@@ -44,7 +44,7 @@
}
define('AC_FILE', __FILE__);
-define('AC_VERSION', '7.1.8');
+define('AC_VERSION', '7.1.9');
require_once ABSPATH . 'wp-admin/includes/plugin.php';
--- a/codepress-admin-columns/vendor/composer/autoload_classmap.php
+++ b/codepress-admin-columns/vendor/composer/autoload_classmap.php
@@ -370,6 +370,7 @@
'AC\Formatter\Date\DateObject' => $baseDir . '/classes/Formatter/Date/DateObject.php',
'AC\Formatter\Date\LocalizedDateFormat' => $baseDir . '/classes/Formatter/Date/LocalizedDateFormat.php',
'AC\Formatter\Date\TimeDifference' => $baseDir . '/classes/Formatter/Date/TimeDifference.php',
+ 'AC\Formatter\Date\TimeElement' => $baseDir . '/classes/Formatter/Date/TimeElement.php',
'AC\Formatter\Date\Timestamp' => $baseDir . '/classes/Formatter/Date/Timestamp.php',
'AC\Formatter\DottedPassword' => $baseDir . '/classes/Formatter/DottedPassword.php',
'AC\Formatter\EmptyValue' => $baseDir . '/classes/Formatter/EmptyValue.php',
--- a/codepress-admin-columns/vendor/composer/autoload_static.php
+++ b/codepress-admin-columns/vendor/composer/autoload_static.php
@@ -414,6 +414,7 @@
'AC\Formatter\Date\DateObject' => __DIR__ . '/../..' . '/classes/Formatter/Date/DateObject.php',
'AC\Formatter\Date\LocalizedDateFormat' => __DIR__ . '/../..' . '/classes/Formatter/Date/LocalizedDateFormat.php',
'AC\Formatter\Date\TimeDifference' => __DIR__ . '/../..' . '/classes/Formatter/Date/TimeDifference.php',
+ 'AC\Formatter\Date\TimeElement' => __DIR__ . '/../..' . '/classes/Formatter/Date/TimeElement.php',
'AC\Formatter\Date\Timestamp' => __DIR__ . '/../..' . '/classes/Formatter/Date/Timestamp.php',
'AC\Formatter\DottedPassword' => __DIR__ . '/../..' . '/classes/Formatter/DottedPassword.php',
'AC\Formatter\EmptyValue' => __DIR__ . '/../..' . '/classes/Formatter/EmptyValue.php',
--- a/codepress-admin-columns/vendor/composer/installed.php
+++ b/codepress-admin-columns/vendor/composer/installed.php
@@ -2,4 +2,4 @@
namespace ACVendor;
-return array('root' => array('name' => '__root__', 'pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '388b9e63d1ea8f1487eafd50d454f5344b86afae', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev' => false), 'versions' => array('__root__' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '388b9e63d1ea8f1487eafd50d454f5344b86afae', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => false), 'laravel/serializable-closure' => array('pretty_version' => 'v1.3.7', 'version' => '1.3.7.0', 'reference' => '4f48ade902b94323ca3be7646db16209ec76be3d', 'type' => 'library', 'install_path' => __DIR__ . '/../laravel/serializable-closure', 'aliases' => array(), 'dev_requirement' => false), 'php-di/invoker' => array('pretty_version' => '2.3.7', 'version' => '2.3.7.0', 'reference' => '3c1ddfdef181431fbc4be83378f6d036d59e81e1', 'type' => 'library', 'install_path' => __DIR__ . '/../php-di/invoker', 'aliases' => array(), 'dev_requirement' => false), 'php-di/php-di' => array('pretty_version' => '6.4.0', 'version' => '6.4.0.0', 'reference' => 'ae0f1b3b03d8b29dff81747063cbfd6276246cc4', 'type' => 'library', 'install_path' => __DIR__ . '/../php-di/php-di', 'aliases' => array(), 'dev_requirement' => false), 'php-di/phpdoc-reader' => array('pretty_version' => '2.2.1', 'version' => '2.2.1.0', 'reference' => '66daff34cbd2627740ffec9469ffbac9f8c8185c', 'type' => 'library', 'install_path' => __DIR__ . '/../php-di/phpdoc-reader', 'aliases' => array(), 'dev_requirement' => false), 'psr/container' => array('pretty_version' => '1.1.2', 'version' => '1.1.2.0', 'reference' => '513e0666f7216c7459170d56df27dfcefe1689ea', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/container', 'aliases' => array(), 'dev_requirement' => false), 'psr/container-implementation' => array('dev_requirement' => false, 'provided' => array(0 => '^1.0'))));
+return array('root' => array('name' => '__root__', 'pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => 'cafedb661e3c791b7f4d50b84f8310f428da614f', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev' => false), 'versions' => array('__root__' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => 'cafedb661e3c791b7f4d50b84f8310f428da614f', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => false), 'laravel/serializable-closure' => array('pretty_version' => 'v1.3.7', 'version' => '1.3.7.0', 'reference' => '4f48ade902b94323ca3be7646db16209ec76be3d', 'type' => 'library', 'install_path' => __DIR__ . '/../laravel/serializable-closure', 'aliases' => array(), 'dev_requirement' => false), 'php-di/invoker' => array('pretty_version' => '2.3.7', 'version' => '2.3.7.0', 'reference' => '3c1ddfdef181431fbc4be83378f6d036d59e81e1', 'type' => 'library', 'install_path' => __DIR__ . '/../php-di/invoker', 'aliases' => array(), 'dev_requirement' => false), 'php-di/php-di' => array('pretty_version' => '6.4.0', 'version' => '6.4.0.0', 'reference' => 'ae0f1b3b03d8b29dff81747063cbfd6276246cc4', 'type' => 'library', 'install_path' => __DIR__ . '/../php-di/php-di', 'aliases' => array(), 'dev_requirement' => false), 'php-di/phpdoc-reader' => array('pretty_version' => '2.2.1', 'version' => '2.2.1.0', 'reference' => '66daff34cbd2627740ffec9469ffbac9f8c8185c', 'type' => 'library', 'install_path' => __DIR__ . '/../php-di/phpdoc-reader', 'aliases' => array(), 'dev_requirement' => false), 'psr/container' => array('pretty_version' => '1.1.2', 'version' => '1.1.2.0', 'reference' => '513e0666f7216c7459170d56df27dfcefe1689ea', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/container', 'aliases' => array(), 'dev_requirement' => false), 'psr/container-implementation' => array('dev_requirement' => false, 'provided' => array(0 => '^1.0'))));