Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/legal-texts-connector-it-recht-kanzlei/legal-texts-connector-it-recht-kanzlei.php
+++ b/legal-texts-connector-it-recht-kanzlei/legal-texts-connector-it-recht-kanzlei.php
@@ -7,16 +7,16 @@
* Author: IT-Recht Kanzlei
* Author URI: https://www.it-recht-kanzlei.de/
* Text Domain: legal-texts-connector-it-recht-kanzlei
- * Version: 1.0.13
- * Stable tag: 1.0.13
+ * Version: 1.0.14
+ * Stable tag: 1.0.14
* Requires at least: 4.4
- * Tested up to: 6.9
+ * Tested up to: 7.0
* Requires PHP: 7.1
* License: GPLv3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
class LegalTextsConnector {
- const VERSION = '1.0.13';
+ const VERSION = '1.0.14';
const PLUGIN_NAME = 'legal-texts-connector-it-recht-kanzlei';
public function __construct() {
--- a/legal-texts-connector-it-recht-kanzlei/src/Document.php
+++ b/legal-texts-connector-it-recht-kanzlei/src/Document.php
@@ -3,22 +3,26 @@
class Document
{
- private $title = null;
- private $country = null;
- private $language = null;
- private $content = null;
- private $type = null;
- private $fileName = null;
- private $creationDate = null;
-
- public function __construct($title, $country, $language, $content, $type, $fileName, $creationDate)
- {
+ private $title = '';
+ private $country = '';
+ private $language = '';
+ private $content = '';
+ private $contentHash = '';
+ private $type = '';
+ private $fileName = '';
+ private $pdfContent = '';
+ private $creationDate;
+
+ public function __construct(
+ $title, $country, $language, $content, $type, $fileName, $pdfContent, $creationDate
+ ) {
$this->title = $title;
$this->country = $country;
$this->language = $language;
$this->content = $content;
$this->type = $type;
$this->fileName = $fileName;
+ $this->pdfContent = $pdfContent;
$this->creationDate = $creationDate;
}
@@ -72,6 +76,18 @@
return $this->creationDate;
}
+ public function getContentHash(): string
+ {
+ if (empty($this->contentHash)) {
+ $content = $this->content;
+ if (($pos = strpos($content, '<div id="itkanzlei_txt_copyright')) > 0) {
+ $content = substr($content, 0, $pos);
+ }
+ $this->contentHash = hash('sha256', $content, false);
+ }
+ return $this->contentHash;
+ }
+
public function getIdentifier(): string
{
return self::createIdentifier($this->type, $this->language, $this->country);
@@ -98,6 +114,16 @@
return self::getFilePath($this->getLanguage(), $this->getCountry(), $this->getType());
}
+ public function getPdfContent(): string
+ {
+ return $this->pdfContent;
+ }
+
+ public function hasPdf(): bool
+ {
+ return !empty($this->pdfContent);
+ }
+
public function getShortCode(): string
{
return ShortCodes::createShortCode($this->getType(), $this->getLanguage(), $this->getCountry());
--- a/legal-texts-connector-it-recht-kanzlei/src/ItrkLtiHandler.php
+++ b/legal-texts-connector-it-recht-kanzlei/src/ItrkLtiHandler.php
@@ -64,6 +64,7 @@
$data->getTextHtml(),
$data->getType(),
$data->getLocalizedFileName(),
+ $data->hasPdf() ? $data->getPdf() : '',
new DateTime()
);
--- a/legal-texts-connector-it-recht-kanzlei/src/MailAttachmentHandler.php
+++ b/legal-texts-connector-it-recht-kanzlei/src/MailAttachmentHandler.php
@@ -138,7 +138,9 @@
try {
$rfc = new ReflectionClass($phpmailer);
$propAttachment = $rfc->getProperty('attachment');
- $propAttachment->setAccessible(true);
+ if (PHP_VERSION_ID < 80100) {
+ $propAttachment->setAccessible(true);
+ }
$propAttachment->setValue($phpmailer, $attachments);
} catch (Exception $e) {}
}
--- a/legal-texts-connector-it-recht-kanzlei/src/Plugin.php
+++ b/legal-texts-connector-it-recht-kanzlei/src/Plugin.php
@@ -15,20 +15,23 @@
const BACKEND_URL = ITRK_SERVICE_URL;
const TARGET_PAGE = '/Portal/schnittstelle_ansicht.php?iid=%d';
- public function init() {
+ const PLUGIN_RESET_ACTION = 'itrk_lti_action_reset';
+
+ public function init(): void {
$pluginIsOpen = is_admin()
&& isset($_GET['page']) && ($_GET['page'] === SettingsPage::PAGE_SETTINGS);
// Reset all settings.
- if ($pluginIsOpen
- && isset($_GET[LegalTextsConnector::PLUGIN_NAME.'-reset']) && ($_GET[LegalTextsConnector::PLUGIN_NAME.'-reset'] === 'true')
- ) {
- self::cleanPluginConfigs();
- $url = add_query_arg(['page' => SettingsPage::PAGE_SETTINGS], admin_url('options-general.php'));
- if (wp_redirect($url)) {
+ add_action('admin_post_'.self::PLUGIN_RESET_ACTION, function () {
+ $redirectUrl = add_query_arg(['page' => SettingsPage::PAGE_SETTINGS], admin_url('options-general.php'));
+ if (!wp_verify_nonce($_GET['_wpnonce'], self::PLUGIN_RESET_ACTION)) {
+ wp_redirect($redirectUrl);
exit;
}
- }
+ self::cleanPluginConfigs();
+ wp_redirect($redirectUrl);
+ exit;
+ });
if (self::isSetup()) {
require_once __DIR__ . '/MailAttachmentHandler.php';
@@ -36,7 +39,7 @@
new ShortCodes();
}
- if (!is_admin()) {
+ if (!is_admin() && !current_user_can('edit_pages')) {
return;
}
@@ -71,8 +74,7 @@
}
}
- /** @return string */
- public static function getAuthToken() {
+ public static function getAuthToken(): string {
if (defined('ITRK_LTI_AUTH_TOKEN') && !empty(ITRK_LTI_AUTH_TOKEN) && is_string(ITRK_LTI_AUTH_TOKEN)) {
return ITRK_LTI_AUTH_TOKEN;
}
@@ -80,8 +82,7 @@
return !empty($token) && is_string($token) ? $token : '';
}
- /** @return ?string */
- public static function getTrinityBrand() {
+ public static function getTrinityBrand(): ?string {
static $trinityBrand = false;
if ($trinityBrand === false) {
$brand = apply_filters('trinity_itrk_brand', null);
@@ -90,7 +91,7 @@
return $trinityBrand;
}
- public static function getAvailableDocuments($type = null) {
+ public static function getAvailableDocuments($type = null): array {
global $wpdb;
if (!in_array($type, ITRechtKanzleiLegalTextSdkLTIPushData::ALLOWED_DOCUMENT_TYPES)) {
return [];
@@ -106,7 +107,7 @@
return $r;
}
- public static function getSupportedLanguages() {
+ public static function getSupportedLanguages(): array {
return [
'de' => __('German', 'legal-texts-connector-it-recht-kanzlei'),
'fr' => __('French', 'legal-texts-connector-it-recht-kanzlei'),
@@ -130,7 +131,7 @@
return $l[$iso] ?? $iso;
}
- public static function getSupportedCountries() {
+ public static function getSupportedCountries(): array {
return [
'DE' => __('Germany', 'legal-texts-connector-it-recht-kanzlei'),
'AT' => __('Austria', 'legal-texts-connector-it-recht-kanzlei'),
@@ -175,7 +176,7 @@
return $t[$type] ?? $type;
}
- public static function isSetup() {
+ public static function isSetup(): bool {
static $isSetup = null;
if ($isSetup === null) {
$isSetup = ($token = self::getAuthToken())
@@ -186,7 +187,16 @@
return $isSetup;
}
- public static function cleanPluginConfigs() {
+ public static function getResetActionUrl(): string {
+ //wp_nonce_url( $bare_url, 'trash-post_'.$post->ID );
+ //admin_url('options-general.php?page='.SettingsPage::PAGE_SETTINGS.'&'.LegalTextsConnector::PLUGIN_NAME.'-reset=true')
+ return wp_nonce_url(
+ admin_url('admin-post.php?action='.self::PLUGIN_RESET_ACTION),
+ self::PLUGIN_RESET_ACTION
+ );
+ }
+
+ public static function cleanPluginConfigs(): void {
global $wpdb;
$wpdb->query($wpdb->prepare(
"DELETE FROM {$wpdb->options} WHERE option_name LIKE %s",
--- a/legal-texts-connector-it-recht-kanzlei/src/SettingsPage.php
+++ b/legal-texts-connector-it-recht-kanzlei/src/SettingsPage.php
@@ -37,12 +37,12 @@
public function addActionLinks($links) {
$links[] =
- '<a href="' . admin_url('options-general.php?page='.self::PAGE_SETTINGS) . '">' . esc_html(__(
+ '<a href="' . esc_attr(admin_url('options-general.php?page='.self::PAGE_SETTINGS)) . '">' . esc_html(__(
'Settings',
'legal-texts-connector-it-recht-kanzlei'
)) . '</a>';
$links[] =
- '<a href="' . admin_url('options-general.php?page='.self::PAGE_SETTINGS.'&'.LegalTextsConnector::PLUGIN_NAME.'-reset=true') . '" style="color:#900">' . esc_html(__(
+ '<a href="' . esc_attr(Plugin::getResetActionUrl()) . '" style="color:#900">' . esc_html(__(
'Reset Settings',
'legal-texts-connector-it-recht-kanzlei'
)) . '</a>';
--- a/legal-texts-connector-it-recht-kanzlei/uninstall.php
+++ b/legal-texts-connector-it-recht-kanzlei/uninstall.php
@@ -6,7 +6,5 @@
die();
}
-if (!class_exists('ITRechtKanzleiLegalTextsConnectorPlugin')) {
- require_once __DIR__ . '/src/Plugin.php';
-}
+require_once __DIR__ . '/src/Plugin.php';
ITRechtKanzleiLegalTextPluginWordpressPlugin::cleanPluginConfigs();