Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/mihdan-no-external-links/admin/MaskTable.php
+++ b/mihdan-no-external-links/admin/MaskTable.php
@@ -179,7 +179,7 @@
case 'title':
$delete_nonce = wp_create_nonce( $this->options_prefix . 'delete_mask' );
- $title = '<strong>' . $item['url'] . '</strong>';
+ $title = '<strong>' . esc_html( $item['url'] ) . '</strong>';
$page = isset( $_REQUEST['page'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['page'] ) ) : '';
$actions = [
@@ -194,7 +194,7 @@
return $title . $this->row_actions( $actions );
case 'mask':
- return (string) $item['mask'];
+ return esc_html( $item['mask'] );
case 'numeric':
return (string) $item['id'];
default:
--- a/mihdan-no-external-links/mihdan-no-external-links.php
+++ b/mihdan-no-external-links/mihdan-no-external-links.php
@@ -10,7 +10,7 @@
* Plugin Name: No External Links
* Plugin URI: https://www.kobzarev.com/projects/no-external-links/
* Description: Convert external links into internal links, site wide or post/page specific. Add NoFollow, Click logging, and more...
- * Version: 5.3.0
+ * Version: 5.3.1
* Author: Mikhail Kobzarev
* Author URI: https://www.kobzarev.com/
* License: GPL-2.0+
@@ -28,7 +28,7 @@
}
const MIHDAN_NO_EXTERNAL_LINKS_DIR = __DIR__;
-const MIHDAN_NO_EXTERNAL_LINKS_VERSION = '5.3.0';
+const MIHDAN_NO_EXTERNAL_LINKS_VERSION = '5.3.1';
const MIHDAN_NO_EXTERNAL_LINKS_SLUG = 'mihdan-no-external-links';
define( 'MIHDAN_NO_EXTERNAL_LINKS_BASENAME', plugin_basename( __FILE__ ) );
--- a/mihdan-no-external-links/public/Frontend.php
+++ b/mihdan-no-external-links/public/Frontend.php
@@ -370,7 +370,7 @@
$this->exclusion_list[] = $url;
- return '<a' . $blank . $nofollow . ' href="' . $url . '" ' . $attributes . '>' . $anchor_text . '</a>';
+ return '<a' . $blank . $nofollow . ' href="' . esc_url( $url ) . '" ' . $attributes . '>' . $anchor_text . '</a>';
}
if ( 'no' !== $this->options->masking_type ) {
@@ -869,8 +869,8 @@
$table_name = $wpdb->prefix . 'external_links_masks';
$long_url = rawurlencode( $url );
- // Restore original URL.
- $url = html_entity_decode( $url, ENT_HTML5 | ENT_QUOTES, get_option( 'blog_charset' ) );
+ // Restore original URL and strip characters that are not allowed in URLs.
+ $url = esc_url_raw( html_entity_decode( $url, ENT_HTML5 | ENT_QUOTES, get_option( 'blog_charset' ) ) );
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
switch ( $this->options->link_shortening ) {
--- a/mihdan-no-external-links/vendor/composer/installed.php
+++ b/mihdan-no-external-links/vendor/composer/installed.php
@@ -1,9 +1,9 @@
<?php return array(
'root' => array(
'name' => 'mihdan/mihdan-no-external-links',
- 'pretty_version' => '5.3.0',
- 'version' => '5.3.0.0',
- 'reference' => 'cee246a6504dd582bf7e3df13551c3ca65bc58b5',
+ 'pretty_version' => '5.3.1',
+ 'version' => '5.3.1.0',
+ 'reference' => '83ea3bd63da093148d02a5138052afdf5597752e',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -11,9 +11,9 @@
),
'versions' => array(
'mihdan/mihdan-no-external-links' => array(
- 'pretty_version' => '5.3.0',
- 'version' => '5.3.0.0',
- 'reference' => 'cee246a6504dd582bf7e3df13551c3ca65bc58b5',
+ 'pretty_version' => '5.3.1',
+ 'version' => '5.3.1.0',
+ 'reference' => '83ea3bd63da093148d02a5138052afdf5597752e',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -47,9 +47,9 @@
'dev_requirement' => false,
),
'phpseclib/phpseclib' => array(
- 'pretty_version' => '3.0.50',
- 'version' => '3.0.50.0',
- 'reference' => 'aa6ad8321ed103dc3624fb600a25b66ebf78ec7b',
+ 'pretty_version' => '3.0.57',
+ 'version' => '3.0.57.0',
+ 'reference' => 'd17e0ddaeaf6f22f7e007cbb437d78792fe2a0e4',
'type' => 'library',
'install_path' => __DIR__ . '/../phpseclib/phpseclib',
'aliases' => array(),
--- a/mihdan-no-external-links/vendor/phpseclib/phpseclib/phpseclib/Crypt/AES.php
+++ b/mihdan-no-external-links/vendor/phpseclib/phpseclib/phpseclib/Crypt/AES.php
@@ -59,7 +59,7 @@
*
* Since phpseclib3CryptAES extends phpseclib3CryptRijndael, this function is, technically, available, but it doesn't do anything.
*
- * @see phpseclib3CryptRijndael::setBlockLength()
+ * @see Rijndael::setBlockLength()
* @param int $length
* @throws BadMethodCallException anytime it's called
*/
--- a/mihdan-no-external-links/vendor/phpseclib/phpseclib/phpseclib/Crypt/ChaCha20.php
+++ b/mihdan-no-external-links/vendor/phpseclib/phpseclib/phpseclib/Crypt/ChaCha20.php
@@ -35,7 +35,7 @@
*
* This is mainly just a wrapper to set things up for phpseclib3CryptCommonSymmetricKey::isValidEngine()
*
- * @see phpseclib3CryptCommonSymmetricKey::__construct()
+ * @see SymmetricKey::__construct()
* @param int $engine
* @return bool
*/
@@ -73,7 +73,7 @@
/**
* Encrypts a message.
*
- * @see phpseclib3CryptCommonSymmetricKey::decrypt()
+ * @see SymmetricKey::decrypt()
* @see self::crypt()
* @param string $plaintext
* @return string $ciphertext
@@ -95,7 +95,7 @@
* $this->decrypt($this->encrypt($plaintext)) == $this->encrypt($this->encrypt($plaintext)).
* At least if the continuous buffer is disabled.
*
- * @see phpseclib3CryptCommonSymmetricKey::encrypt()
+ * @see SymmetricKey::encrypt()
* @see self::crypt()
* @param string $ciphertext
* @return string $plaintext
--- a/mihdan-no-external-links/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/AsymmetricKey.php
+++ b/mihdan-no-external-links/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/AsymmetricKey.php
@@ -79,18 +79,19 @@
private static $invisiblePlugins = [];
/**
- * Available Engines
+ * Key Comment
*
- * @var boolean[]
+ * @var null|string
*/
- protected static $engines = [];
+ private $comment;
/**
- * Key Comment
+ * OpenSSL configuration file name.
*
- * @var null|string
+ * @see self::createKey()
+ * @var ?string
*/
- private $comment;
+ protected static $configFile;
/**
* @param string $type
@@ -119,6 +120,10 @@
self::$one = new BigInteger(1);
}
+ if (!isset(self::$configFile)) {
+ self::$configFile = dirname(__FILE__) . '/../../openssl.cnf';
+ }
+
self::loadPlugins('Keys');
if (static::ALGORITHM != 'RSA' && static::ALGORITHM != 'DH') {
self::loadPlugins('Signature');
@@ -364,6 +369,18 @@
}
/**
+ * Sets the OpenSSL config file path
+ *
+ * Set to the empty string to use the default config file
+ *
+ * @param string $val
+ */
+ public static function setOpenSSLConfigPath($val)
+ {
+ self::$configFile = $val;
+ }
+
+ /**
* Add a fileformat plugin
*
* The plugin needs to either already be loaded or be auto-loadable.
@@ -419,34 +436,28 @@
}
/**
- * Tests engine validity
- *
+ * Force engine (useful for unit testing)
*/
- public static function useBestEngine()
+ public static function forceEngine($engine = null)
{
- static::$engines = [
- 'PHP' => true,
- 'OpenSSL' => extension_loaded('openssl'),
- // this test can be satisfied by either of the following:
- // http://php.net/manual/en/book.sodium.php
- // https://github.com/paragonie/sodium_compat
- 'libsodium' => function_exists('sodium_crypto_sign_keypair')
- ];
-
- return static::$engines;
+ if (!isset($engine)) {
+ static::$forcedEngine = null;
+ return;
+ }
+ switch ($engine) {
+ case 'PHP':
+ case 'OpenSSL':
+ case 'libsodium':
+ static::$forcedEngine = $engine;
+ break;
+ default:
+ throw new InvalidArgumentException('Valid engines are null, PHP, OpenSSL or libsodium');
+ }
}
- /**
- * Flag to use internal engine only (useful for unit testing)
- *
- */
- public static function useInternalEngine()
+ public static function getForcedEngine()
{
- static::$engines = [
- 'PHP' => true,
- 'OpenSSL' => false,
- 'libsodium' => false
- ];
+ return static::$forcedEngine;
}
/**
--- a/mihdan-no-external-links/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/OpenSSH.php
+++ b/mihdan-no-external-links/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/OpenSSH.php
@@ -118,7 +118,7 @@
return compact('type', 'publicKey', 'paddedKey');
}
- $parts = preg_split("#[t ]+#", $key);
+ $parts = preg_split("#[t ]+#", $key, 3);
if (!isset($parts[1])) {
$key = base64_decode($parts[0]);
--- a/mihdan-no-external-links/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php
+++ b/mihdan-no-external-links/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php
@@ -565,7 +565,7 @@
],
'privateKey' => $key
];
- if ($oid != 'id-Ed25519' && $oid != 'id-Ed448') {
+ if ($oid != 'id-Ed25519' && $oid != 'id-Ed448' && $oid != 'id-X25519' && $oid != 'id-X448') {
$key['privateKeyAlgorithm']['parameters'] = $params;
}
if (!empty($attr)) {
@@ -682,7 +682,7 @@
'publicKey' => "