fix: add type and data-ajax-nonce to button kses allowlist#879
fix: add type and data-ajax-nonce to button kses allowlist#879superdav42 merged 2 commits intomainfrom
Conversation
The setup wizard requirements table HTML passes through wp_kses() twice (field-note.php and default.php templates). The button element's kses allowlist only permitted disabled, name, and value — stripping type="button" and data-ajax-nonce from the Network Activate button. Without type="button", the click submits the parent form instead of triggering the AJAX handler. Without data-ajax-nonce, the JS reads undefined and the server rejects the request with bad-nonce. PR #875 correctly moved the JS to an external file and changed the nonce field to _ajax_nonce, but the button attributes were still stripped before reaching the browser.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
|
Performance Test Results Performance test results for 9908421 are in 🛎️! Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown. URL:
|
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
Summary
typeanddata-ajax-nonceto the<button>allowlist inwu_kses_allowed_html(), fixing the setup wizard Network Activate buttonRoot Cause
The setup wizard requirements table HTML passes through
wp_kses()twice — once infield-note.php(line 33) and again indefault.php(line 20). The<button>element's kses allowlist only permitteddisabled,name, andvalue.This stripped two critical attributes from the Network Activate button:
type="button"type="submit", submitting the wizard form instead of firing the AJAX handlerdata-ajax-nonce="..."undefined, sends no nonce → server responds{"success":false,"data":[{"code":"bad-nonce",...}]}PR #875 correctly moved the JS to an external file and switched to
_ajax_nonce/data-ajax-nonce, but the button attributes were still stripped bywp_kses()before reaching the browser.Fix
One-line change to
inc/functions/helper.php— addstypeanddata-ajax-nonceto the button's kses allowlist. Both are standard HTML attributes that pose no XSS risk.Verification
Tested on http://wordpress.local:8080 setup wizard:
type="button"anddata-ajax-nonce="<valid>"in DOM_ajax_nonce=<value>in POST body{"success":true}Summary by CodeRabbit