Skip to content

Commit 2982bb6

Browse files
Andrew Bakerclaude
andcommitted
v1.7.21 — PCP compliance: fix readme tags, description, phpcs:ignore, JS error handling
Critical (WordPress.org): readme.txt tags reduced from 8 to 5; short description trimmed to 141 chars. Medium: Requires at least corrected to 6.0; phpcs:ignore added on POST reads validated via custom methods; .catch() on clipboard promise; console.error() in settings save catch; onclick removed from toast button in favour of addEventListener. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5557808 commit 2982bb6

File tree

6 files changed

+37
-12
lines changed

6 files changed

+37
-12
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
66

77
## [Unreleased]
88

9+
## [1.7.21] - 2026-03-22
10+
11+
### Fixed
12+
- `readme.txt`: Reduced tags from 8 to 5 (WordPress.org enforces a maximum of 5)
13+
- `readme.txt`: Shortened short description to 141 characters (WordPress.org maximum is 150)
14+
- `readme.txt`: Updated `Requires at least` from 5.8 to 6.0 to match plugin header
15+
- `cs-code-block.php`: Added `phpcs:ignore InputNotSanitized` on `$_POST['sql']` — validated via `is_safe_query()`, not a standard `sanitize_*()` call
16+
- `cs-code-block.php`: Added `phpcs:ignore InputNotSanitized` on `$_POST['post_id']` reads in `ajax_preview()` and `ajax_migrate_single()` — sanitised via `(int)` cast
17+
- `cs-convert.js`: Removed `onclick` attribute from JS-generated toast button; replaced with `addEventListener`
18+
- `cs-code-block.js`: Added `.catch()` to `copyToClipboard()` promise chain — logs clipboard API rejection via `console.error()`
19+
- `cs-admin-settings.js`: Added `console.error()` to settings save `.catch()` block
20+
921
## [1.7.18] - 2026-03-13
1022

1123
### Security

assets/cs-admin-settings.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@
3838
}, 2000 );
3939
}
4040
} )
41-
.catch( function() {
41+
.catch( function( e ) {
4242
saveBtn.disabled = false;
4343
saveBtn.textContent = '💾 Save Settings';
44+
console.error( 'cs-code-block: settings save failed', e );
4445
} );
4546
} );
4647
} )();

assets/cs-code-block.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@
199199
setTimeout( function() {
200200
copyBtn.classList.remove( 'copied' );
201201
}, 2000 );
202+
} ).catch( function( e ) {
203+
console.error( 'cs-code-block: clipboard write failed', e );
202204
} );
203205
} );
204206
}

assets/cs-convert.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@
125125
var s = coreBlocks.length > 1 ? 's' : '';
126126
toast.innerHTML = '' +
127127
'<span>\u26A0\uFE0F ' + coreBlocks.length + ' core code block' + s + ' found</span>' +
128-
'<button onclick="window.__csConvertAll()">\u26A1 Convert All to CloudScale</button>';
128+
'<button>\u26A1 Convert All to CloudScale</button>';
129+
toast.querySelector( 'button' ).addEventListener( 'click', convertAll );
129130
} else {
130131
if ( toast ) {
131132
toast.remove();

cs-code-block.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: CloudScale Code Block
44
* Plugin URI: https://andrewbaker.ninja
55
* Description: Syntax highlighted code block with auto language detection, clipboard copy, dark/light mode toggle, code block migrator, and read only SQL query tool. Works as a Gutenberg block and as a [cs_code] shortcode.
6-
* Version: 1.7.19
6+
* Version: 1.7.21
77
* Author: Andrew Baker
88
* Author URI: https://andrewbaker.ninja
99
* License: GPL-2.0-or-later
@@ -31,7 +31,7 @@
3131
*/
3232
class CloudScale_Code_Block {
3333

34-
const VERSION = '1.7.19';
34+
const VERSION = '1.7.21';
3535
const HLJS_VERSION = '11.11.1';
3636
const HLJS_CDN = 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/';
3737
const TOOLS_SLUG = 'cloudscale-code-sql';
@@ -952,7 +952,7 @@ public static function ajax_sql_run(): void {
952952
wp_send_json_error( 'Bad nonce', 403 );
953953
}
954954

955-
$raw = isset( $_POST['sql'] ) ? $_POST['sql'] : '';
955+
$raw = isset( $_POST['sql'] ) ? $_POST['sql'] : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash -- raw SQL for admin tool; unslashed on next line, validated via is_safe_query()
956956
$sql = trim( wp_unslash( $raw ) );
957957
if ( ! $sql ) {
958958
wp_send_json_error( 'Empty query' );
@@ -1304,7 +1304,7 @@ public static function ajax_preview() {
13041304
wp_send_json_error( 'Bad nonce', 403 );
13051305
}
13061306

1307-
$post_id = (int) ( $_POST['post_id'] ?? 0 );
1307+
$post_id = (int) ( $_POST['post_id'] ?? 0 ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- sanitised via (int) cast
13081308
$post = get_post( $post_id );
13091309

13101310
if ( ! $post ) {
@@ -1336,7 +1336,7 @@ public static function ajax_migrate_single() {
13361336
wp_send_json_error( 'Bad nonce', 403 );
13371337
}
13381338

1339-
$post_id = (int) ( $_POST['post_id'] ?? 0 );
1339+
$post_id = (int) ( $_POST['post_id'] ?? 0 ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- sanitised via (int) cast
13401340
$post = get_post( $post_id );
13411341

13421342
if ( ! $post ) {

readme.txt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
=== CloudScale Code Block ===
22
Contributors: andrewbaker
3-
Tags: code, syntax highlighting, highlight.js, developer, gutenberg block, sql, code block, dark mode
4-
Requires at least: 5.8
3+
Tags: code block, syntax highlighting, gutenberg block, dark mode, highlight.js
4+
Requires at least: 6.0
55
Tested up to: 6.7
66
Requires PHP: 7.4
7-
Stable tag: 1.7.19
7+
Stable tag: 1.7.21
88
License: GPLv2 or later
99
License URI: https://www.gnu.org/licenses/gpl-2.0.html
1010

11-
Syntax highlighted code block with 14 color themes, auto language detection, clipboard copy, dark/light toggle, code block migrator, and read only SQL query tool.
11+
Syntax highlighted code block with 14 color themes, auto language detection, clipboard copy, dark/light toggle, migrator, and SQL query tool.
1212

1313
== Description ==
1414

@@ -79,7 +79,16 @@ Yes. Press Enter to run the query. Use Shift+Enter to insert a newline. Ctrl+Ent
7979

8080
== Changelog ==
8181

82-
= 1.7.19 =
82+
= 1.7.21 =
83+
* Fixed: readme.txt tags reduced from 8 to 5 (WordPress.org maximum)
84+
* Fixed: readme.txt short description trimmed to 141 chars (maximum is 150)
85+
* Fixed: readme.txt Requires at least updated to 6.0 to match plugin header
86+
* Fixed: phpcs:ignore comments added on POST reads validated via custom methods
87+
* Fixed: inline onclick removed from toast button in cs-convert.js; replaced with addEventListener
88+
* Fixed: .catch() added to clipboard promise chain in cs-code-block.js
89+
* Fixed: console.error() added to settings save catch block in cs-admin-settings.js
90+
91+
= 1.7.20 =
8392
* Security: is_safe_query() now rejects queries containing semicolons, preventing statement stacking
8493
* Security: Removed $_REQUEST fallback in SQL AJAX handler
8594
* Fixed: Echoed <style> block removed from admin page; inline <script> blocks extracted to enqueued JS files (PCP compliance)

0 commit comments

Comments
 (0)