Repository navigation
Validated header and footer row text colors - #4710
girishpanchal30 wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes requested
The text color fix works, but other row and ability values still print raw into CSS, and Configure hides rejected colors.
header-footer-grid/Core/Builder/Abstract_Builder.php:2063—security✓ Verified in the sandbox The footer row Vertical Alignment setting has the same flaw as the Text Color fix. It useswp_filter_nohtml_kses, which only strips tags. Its value is printed raw as--valign. A user withoutunfiltered_htmlcan savetop;}body{background:lime}/*, and the front end prints--valign: top;}body{background:lime}/*. Replace the callback with one that accepts only the radio choices (flex-start,center,flex-end). Add aMETA_FILTERon--valignthat falls back to the default for stored values. Add a case totests/test-neve-row-text-color.phpthat saves the payload and asserts thatlimeis not in the CSS.header-footer-grid/Core/Builder/Abstract_Builder.php:1067-1069—security✓ Verified in the sandbox A stored row background color still prints raw. Before this PR, Header and Footer Configure savedbackground.colorValuewith onlysanitize_text_field, so sites can already hold#222;}body{background:lime}/*there. The new--colorfilter covers stored text colors for this reason, but--bgcolorand--overlaycolorhave no filter. The front end prints--bgcolor: #222;}body{background:lime}/*;. Add aMETA_FILTERto--bgcolorand--overlaycolorthat runsneve_sanitize_colors()and falls back to the default. Add an output case that stores the payload inhfg_footer_layout_main_backgroundand asserts thatlimeis not in the CSS.inc/abilities/appearance_update.php:428-441—security✓ Verified in the sandbox Theneve/appearance-updateability storesfontWeightwith no validation. A bodyfontWeightof400;}body{background:lime}/*prints--bodyfontweight: 400;}body{background:lime}/*;on the front end. Heading and button weights take the same path. Accept only the numeric weights100to900(andnormal,bold) for every typography target, and reject anything else with a validation error. Add a test that sends the payload for the body, a heading and the button, and asserts thatlimeis not in the CSS.
Validation details
- Files reviewed: 5/5 changed files. Unchecked rows: issue #3820 PHPStan; precedent #4678 suffix-based sanitizer shapes; Failure direction: Causes, Too permissive, Too strict, Direction.
- The new tests pass at HEAD (run R8) and fail on the base tree (run R9), PHP 8.3, WordPress 7.1.5.
- Payload runs on the other paths ran at HEAD and base (runs R14 and R15).
- Font family and allowlisted dimension keys in the abilities also print raw values. Those paths predate this change (run R18).
Untested areas
- PHPStan was not installed, so issue #3820 PHPStan was not checked.
- Precedent #4678 suffix-based sanitizer shapes: filter-added allowlist keys were not checked.
- Failure direction: Causes, Too permissive, Too strict, Direction: legacy background shapes from older versions were not checked.
- Customizer font family settings were not executed.
🤖 Automated review · run code-review-agent_6afff007a00e61.28722729.
🤖 Review agent — review posted ✅ on 13855e1c · changes requested · 5 findings · 42 min
Run code-review-agent_6afff007a00e61.28722729 · trail
|
Review item F4: Valid finding, but outside this PR: |
There was a problem hiding this comment.
🟡 Changes requested
The row height, alignment, background and warning fixes work, but the appearance ability still prints font weight and font family raw into CSS.
inc/abilities/appearance_update.php:441—security✓ Verified in the sandbox This is still open from the earlier review. Theneve/appearance-updateability storesfontWeightwith no validation. A bodyfontWeightof400;}body{background:lime}/*prints--bodyfontweight: 400;}body{background:lime}/*;on the front end. Heading and button weights take the same path. Accept only the numeric weights100to900(andnormal,bold) for every typography target. Reject anything else with a validation error. Add a test that sends the payload for the body, a heading and the button, and asserts thatlimeis not in the CSS.inc/abilities/appearance_update.php:425—securityTheneve/appearance-updateability stores the body and heading font family with onlysanitize_text_field. That function keepsArial;}body{background:lime}/*, because the value has no tags or spaces to strip. The CSS output prints a family without spaces unquoted, so the front end gets--bodyfontfamily: Arial;}body{background:lime}/*;. The font weight fix does not cover this field. Reject a font family that contains;,{,},(,)or/*with a validation error. Add a test that sends the payload for the body and a heading, and asserts thatlimeis not in the CSS.
Validation details
- Files reviewed: 8/8 changed files. Unchecked rows: issue #3820 PHPStan; Failure direction: Causes, Too permissive, Too strict, Direction, Visibility.
- The row tests pass at HEAD
set -o pipefail; cd /var/www/html/wp-content/themes/neve; timeout 280 phpunit --do-not-cache-result --filter 'TestNeveRo…printedOK (8 tests, 42 assertions)(run R7) and fail on the base treeset -o pipefail; cd /var/www/html/wp-content/themes/neve-base; timeout 280 phpunit --do-not-cache-result --filter 'TestN…printedTests: 8, Assertions: 10, Failures: 8.(run R5). - The footer alignment and row background fixes from the earlier review are confirmed by these tests.
- The font weight payload still reaches the CSS at HEAD
set -o pipefail; mkdir -p /workspace/checks/C1/c; cd /var/www/html/wp-content/themes/neve; sed 's#/workspace/checks/C11/…printed"lime_in_css": true(run R8). - The font family result reuses run code-review-agent_6afff007a00e61.28722729, not rerun.
- Question:
CONTRIBUTING.mdputs unit tests intests/php/unit, butphpunit.xmlrunstests/. Should the document change?
Untested areas
- PHPStan could not be installed, so issue #3820 PHPStan was not checked.
- Failure direction: Causes, Too permissive, Too strict, Direction, Visibility were not settled for the background rejection.
- Older stored footer alignment values were not found.
- Dimension keys in the theme mod ability were not checked.
- The variant pass did not settle these places, where the fixed cause may still reach:
header-footer-grid/Core/Builder/Abstract_Builder.php:1039-1042,1062-1065,1075-1077,2100-2105— unverified: Text color, --bgcolor and --overlaycolor now have output guards, including for already-stored values. Complete validation depends partly on WordPress sanitize_hex_color; installed …globals/sanitize-functions.php:69-97— unverified: Text color, --bgcolor and --overlaycolor now have output guards, including for already-stored values. Complete validation depends partly on WordPress sanitize_hex_color; installed …header-footer-grid/Core/Components/Abstract_Component.php:686-689,824-837— unverified: Component/global font-family paths remain unchanged. A no-space declaration-breaking string remains unquoted by the formatter; whether the installed sanitize_text_field preserves i…inc/core/styles/css_vars.php:252-255,282-284— unverified: Component/global font-family paths remain unchanged. A no-space declaration-breaking string remains unquoted by the formatter; whether the installed sanitize_text_field preserves i…inc/core/styles/css_prop.php:383-415— unverified: Component/global font-family paths remain unchanged. A no-space declaration-breaking string remains unquoted by the formatter; whether the installed sanitize_text_field preserves i…inc/abilities/site_set_theme_mod.php:26-51,175-185,201-210— unverified: Allowlisted sidebar/form/scroll-to-top dimensions still bypass color/background validation. The prior responsive/directional/unit candidates remain unresolved pending installed san…inc/abilities/abstract_ability.php:246-259— unverified: Allowlisted sidebar/form/scroll-to-top dimensions still bypass color/background validation. The prior responsive/directional/unit candidates remain unresolved pending installed san…
🤖 Automated review · run code-review-agent_6b000d0d667fd0.35707748.
🤖 Review agent — review posted ✅ on cc3240a7 · changes requested · 2 findings · 20 min
Run code-review-agent_6b000d0d667fd0.35707748 · trail
There was a problem hiding this comment.
🟡 Changes requested
The font weight fix works, but font family, nested colors and dimension values from two abilities still reach the CSS unchecked.
Validation details
- Files reviewed: 2/2 files changed since the last review. Unchecked rows: issue #3820 PHPStan; Failure direction: Causes, Too permissive, Too strict, Direction, Visibility.
- The new font test passes at HEAD
set -o pipefail; rsync -a --delete --exclude .git /repo/ /var/www/html/wp-content/themes/neve/ && cd /var/www/html/wp-co…printedOK (2 tests, 25 assertions)(run R4) and fails on the base treecd /workspace/checks/R1; set -o pipefail; timeout 290 sandbox-phpunit-ab.sh /workspace/checks/R1/head 80458289bc2be8c0ba…(run R19, exit 0). - Invalid font weights now return
ability_invalid_inputthrough the run route, dispatched in process `cd /workspace/checks/R1/head; cat > tests/test-r1-rest-probe.php <<'EOF'
Untested areas
- PHPStan could not be installed, so issue #3820 PHPStan was not checked. - Failure direction: Causes, Too permissive, Too strict, Direction, Visibility were not settled for the background rejection. - The theme is not active over HTTP in the sandbox. REST checks ran in process.There was a problem hiding this comment.
🟡 Changes requested
The four earlier findings are fixed, but five other Customizer and ability paths still let a saved value close its CSS rule.
globals/sanitize-functions.php:256—security✓ Verified in the sandbox The Customizer path still stores CSS-closing button colors.neve_sanitize_button_appearance()returns its value unchanged. The registered sanitizer ofnav-icon_button_appearancekeeps abackgroundof#222;}body{background:lime}/*, andset_theme_mod()stores it. The generated CSS then contains--bgcolor: #222;}body{background:lime}/*;. This PR now rejects that value fornav-icon_button_appearanceinneve/site-set-theme-mod, but not in the Customizer. This code was already present before this PR. Validatebackgroundandtextwithneve_sanitize_colors()in this function. Add a Customizer-save test that assertslimeis not in the CSS.globals/sanitize-functions.php:294—securityThe Customizer path still stores CSS-closing component line heights.neve_sanitize_typography_control()only checks thatlineHeight,letterSpacingandfontSizeare arrays. It does not check the values inside them. A Customizer save withlineHeight.mobileset to1;}body{background:lime}/*keeps the value.CSS_Propthen prints it raw in the responsive rule, so the generated CSS gets a newbodyrule. This code was already present before this PR. Validate each responsive value as a number and each suffix as an allowed unit here. Add a Customizer-save test that assertslimeis not in the CSS.header-footer-grid/Traits/Core.php:135—securityThe Customizer path still stores CSS-closing component padding and margin values. The array branch ofsanitize_spacing_array()returns its input unchanged. A Customizer save with a side such astopset to1;}body{background:lime}/*keeps the value.CSS_Propconcatenates each side into the directional rule, so the generated CSS gets a newbodyrule. This code was already present before this PR. Cast each side to a number and allow only known units here. Add padding and margin Customizer-save tests that assertlimeis not in the CSS.header-footer-grid/Core/Components/Abstract_Component.php:847—security✓ Verified in the sandbox The Customizer path still stores CSS-closing component font families. The font family setting uses onlysanitize_text_field(), which keeps;,{and}. The registered sanitizer ofprimary-menu_component_font_familykeepsArial;}body{background:lime}/*, andset_theme_mod()stores it. The generated CSS then contains--fontfamily: Arial;}body{background:lime}/*;. This code was already present before this PR. Use a sanitize callback that rejects a font family containing;,{,},<or/*, like the PR'sFONT_FAMILY_PATTERN. Add a Customizer-save test that assertslimeis not in the CSS.inc/abilities/schema_helpers.php:144—security✓ Verified in the sandboxneve/appearance-updatestill prints an undeclared radius unit raw.box_model_schema()declares only the four sides and does not setadditionalProperties: false. So WordPress accepts an extraunitkey. Abuttons.primary.radius.unitofpx;}body{background:lime}/*is merged intoneve_button_appearanceunchanged. The generated CSS contains--primarybtnborderradius:3px;}body{background:lime}/*;. This code was already present before this PR. Set'additionalProperties' => falseinbox_model_schema(), or declareunitwith an enum of allowed units. Add a test that sends this payload and assertslimeis not in the CSS.
Validation details
- Files reviewed: 6/6 files changed since the last review. Unchecked rows: issue #3820 PHPStan; Appearance_Update::button_schema() return changed; Appearance_Update::get_input_schema() return changed; Failure direction: Visibility.
- The new tests pass at HEAD
mkdir -p /workspace/checks/R2b; set -o pipefail; F='test_font_weight_none_is_saved|test_font_families_reject_text_escape…printedOK (4 tests, 48 assertions)(run R8). Three of them fail on the base treemkdir -p /workspace/checks/R2b; set -o pipefail; F='test_font_weight_none_is_saved|test_font_families_reject_text_escape…printedTests: 4, Assertions: 9, Failures: 3.(run R8). - The Customizer sanitizer probe ran at HEAD `mkdir -p /workspace/checks/V3 && cat > /workspace/checks/V3/test-v3-probe.php <<'EOF'
Untested areas
- PHPStan is not installed, so issue #3820 PHPStan was not checked. - Appearance_Update::button_schema() return changed, Appearance_Update::get_input_schema() return changed and Failure direction: Visibility were not settled. - Footer and secondary menu font families were not placed in the layout, so their CSS was not run. - The site is not served over HTTP. All checks ran in PHPUnit. - The variant pass did not settle these places, where the fixed cause may still reach: - `inc/abilities/appearance_update.php:439-448,518-566` — unverified: Numeric fields and enums constrain declared properties, but merged objects preserve incoming properties. Explore should verify version-matched WordPress validation of undeclared fi…There was a problem hiding this comment.
🟡 Changes requested
The five earlier findings are fixed, but the new dimension sanitizer erases the "No unit" line height choice of header and footer components.
Validation details
- Files reviewed: 8/8 files changed since the last review. Unchecked rows: issue #3820 PHPStan; Builder_Configure::get_builder() return changed; Schema_Helpers::box_model_schema() return changed; Failure direction: Causes, Too strict and Visibility.
- The six new tests pass at HEAD
set -o pipefail; cd /workspace/checks/R1 && rm -rf src && mkdir -p src && git clone -q --no-hardlinks /repo src/neve 2>&…printedOK (6 tests, 40 assertions)(run R6). Each fails on the base treeset -o pipefail; cd /workspace/checks/R1 && rm -rf base && mkdir base && cp -a src/neve base/neve && cd base/neve && git…printedFailures: 6(run R7). - A component line height saved with "No unit" stores an empty suffix at HEAD [R10] and
—on the base tree [R11]. Both print--lineheight: 1.6;.
Untested areas
- PHPStan is not installed.
- Stored palette, blog card and archive values print raw if a delimiter is already stored. Their writers were not traced.
- Malformed colors such as
rgb(1)still pass the unchanged color sanitizer. Whether the PR promises full color validity was not settled. - The Customizer screen was not opened. All runs used PHPUnit.
- The variant pass did not settle these places, where the fixed cause may still reach:
inc/abilities/appearance_update.php:439-448,518-566— unverified: Carried-forward merged-object question: incoming undeclared properties survive the local merges, but declaring injection reachable requires the installed WordPress Abilities API’s …
🤖 Automated review · run code-review-agent_6b0028ae8242e3.99148280.
🤖 Review agent — review posted ✅ on 10422d2c · changes requested · 2 findings · 32 min
Run code-review-agent_6b0028ae8242e3.99148280 · trail
There was a problem hiding this comment.
🟢 Approved
The PR passes. The "No unit" line height fix and the new getter test resolve both earlier findings.
Validation details
- Files reviewed: 3/3 files changed since the last review. Unchecked rows: issue #3820 PHPStan; issue #3300 background alignment warning; Builder_Configure::get_builder() return changed; Failure direction: Causes, Too strict and Visibility.
- PHPUnit at HEAD printed
cd /workspace/checks/R1; rm -rf head ten prb; for p in "t-head head" "t-10422 ten" "t-prbase prb"; do set -- $p; mkdir -…printedOK (7 tests, 40 assertions)(run R5). - With the 10422d2 code, the run printed
cd /workspace/checks/R1; grep -E "✘|✔" run-10422-nontest.log; grep -n "Failed\|Error" run-10422-nontest.log | head -5; e…printed✘ No unit line height is kept(run R7). - Without the getter
css_unit()calls, the run printedcd /workspace/checks/R1; rm -rf mut; mkdir mut; cp -a head/neve mut/; cp -a head/neve/vendor mut/neve/ 2>/dev/null; f=mu…printed✘ Responsive unit getters reject stored units(run R8). - Extra ability properties reach CSS only through
css_unit(), which falls back topx.
Untested areas
- PHPStan is not installed.
- The unchecked rows above were not settled.
- The variant and requirements passes were not rerun.
- Legacy font values copied by
Mods_Migratorwere not checked for strings such as16px. - The Customizer screen was not opened.
Questions for the author
- Can stored typography or spacing settings hold strings such as
10px?neve_sanitize_css_dimensions()clears them.
🤖 Automated review · run code-review-agent_6b00321e3a1519.31229138.
🤖 Review agent — review posted ✅ on a86a3f45 · approved · 0 findings · 25 min
Run code-review-agent_6b00321e3a1519.31229138 · trail
Summary
Strengthened sanitization and validation of row text and background color settings in the header and footer builder by introducing a consistent approach across Customizer settings, theme mod storage, and dynamic CSS output. Ensured that only valid color values are accepted and rendered, and added comprehensive unit tests covering sanitization, validation, and output behavior.
Check before Pull Request is ready:
Closes #4708