Skip to content

Commit c9a2343

Browse files
committed
Handle null bytes in more places
1 parent 52d4790 commit c9a2343

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

html-api-debugger/html-api-debugger.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: HTML API Debugger
44
* Plugin URI: https://github.com/sirreal/html-api-debugger
55
* Description: Add a page to wp-admin for debugging the HTML API.
6-
* Version: 2.5
6+
* Version: 2.6
77
* Requires at least: 6.7
88
* Tested up to: 6.8
99
* Author: Jon Surrell
@@ -22,7 +22,7 @@
2222
require_once __DIR__ . '/html-api-integration.php';
2323

2424
const SLUG = 'html-api-debugger';
25-
const VERSION = '2.5';
25+
const VERSION = '2.6';
2626

2727
/** Set up the plugin. */
2828
function init() {

html-api-debugger/interactivity.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class="context-html"
7979
<div>
8080
<h2>Input HTML</h2>
8181
<textarea
82-
id='input_html'
82+
id="input-html"
8383
autocapitalize="off"
8484
autocomplete="off"
8585
spellcheck="false"
@@ -153,7 +153,7 @@ class="context-html"
153153
<label>Show invisible <input type="checkbox" data-wp-bind--checked="state.showInvisible" data-wp-on-async--input="handleShowInvisibleClick"></label>
154154
<span><label>Show virtual <input type="checkbox" data-wp-bind--checked="state.showVirtual" data-wp-on-async--input="handleShowVirtualClick"></label></span>
155155
<div data-wp-bind--hidden="!state.htmlapiResponse.supports.selectors">
156-
<label>CSS Selectors <textarea placeholder="CSS selector: .my-class" data-wp-on-async--input="handleSelectorChange"><?php echo "\n" . esc_textarea( str_replace( "\0", '', $options['selector'] ?? '' ) ); ?></textarea></label>
156+
<label>CSS Selectors <textarea id="selector-input" placeholder="CSS selector: .my-class" data-wp-on-async--input="handleSelectorChange"><?php echo "\n" . esc_textarea( str_replace( "\0", '', $options['selector'] ?? '' ) ); ?></textarea></label>
157157
</div>
158158
</div>
159159
<div>

html-api-debugger/readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: jonsurrell, bernhard-reiter
33
Tags: HTML API, development, debug
44
Requires at least: 6.7
55
Tested up to: 6.8
6-
Stable tag: 2.5
6+
Stable tag: 2.6
77
License: GPLv2 or later
88
License URI: https://www.gnu.org/licenses/gpl-2.0.html
99

@@ -15,6 +15,9 @@ Please file issues and pull requests on the [GitHub repository](https://github.c
1515

1616
== Changelog ==
1717

18+
= 2.6 =
19+
* Handle null bytes in selectors and context HTML.
20+
1821
= 2.5 =
1922
* Fix a crash when using WordPress 6.7.
2023

html-api-debugger/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
font-size: inherit;
5959
}
6060

61-
#input_html {
61+
#input-html {
6262
width: 100%;
6363
min-height: 200px;
6464
font-family: var(--monospace-font-family);

html-api-debugger/view.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ let mutationObserver = null;
6969
*
7070
* @typedef State
7171
* @property {ReadonlyArray<string>} treeWarnings
72-
* @property {string|null} selector
72+
* @property {string} selector
7373
* @property {string|null} selectorErrorMessage
7474
* @property {boolean} showClosers
7575
* @property {boolean} showInvisible
@@ -354,9 +354,19 @@ const store = createStore(NS, {
354354
// Force print them if we have null bytes.
355355
if (store.state.html.includes('\0')) {
356356
/** @type {HTMLTextAreaElement} */ (
357-
document.getElementById('input_html')
357+
document.getElementById('input-html')
358358
).value = store.state.html;
359359
}
360+
if (store.state.contextHTML.includes('\0')) {
361+
/** @type {HTMLTextAreaElement} */ (
362+
document.getElementById('context-html')
363+
).value = store.state.contextHTML;
364+
}
365+
if (store.state.selector.includes('\0')) {
366+
/** @type {HTMLTextAreaElement} */ (
367+
document.getElementById('selector-input')
368+
).value = store.state.selector;
369+
}
360370

361371
store.render();
362372

0 commit comments

Comments
 (0)