Repository navigation
Close outdated style validation changes - #4690
girishpanchal30 wants to merge 16 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes requested
Ability writes of other style keys still store injectable CSS, and the CSS output still prints stored row colors raw, so the reported issue stays open.
header-footer-grid/Core/Builder/Abstract_Builder.php:1036—securityThis PR closes neve-pro-addon#3310, but the reported trigger is unchanged. The issue saveshfg_header_layout_main_border_colorin the Customizer with Pro active. This assumes, as the issue reports, that the Pro save stores the value raw. The PR only changes the abilities, which never write_border_color. In the sandbox, a storedrgba(1,2,3,1);}body{background:lime}/*still prints--rowbcolor: rgba(1,2,3,1);}body{background:lime}/*;. This rule has no filter, soCss_Prop::transform()prints the value raw. Give--rowbcoloraMETA_FILTERthat runsneve_sanitize_colors()and returns the formatted rule. That also fixes values already stored. Otherwise fix the Pro save and keep #3310 open. Add a test that renders the row CSS.header-footer-grid/Core/Builder/Abstract_Builder.php:1042—security✓ Verified in the sandbox Row colors that the abilities stored before this change still print raw CSS. The previous version storedtext_colorand backgroundcolorValueunchanged. The--colorand--bgcolorrules have no filter, andCss_Prop::transform()prints their values raw. After the upgrade, an injected value still prints--color: rgba(1,2,3,1);}body{background:lime}/*;on every page. Sanitize these values when the CSS is built: give--color,--bgcolorand--overlaycoloraMETA_FILTERthat runsneve_sanitize_colors()and returns the formatted rule, or''when the color is empty. Otherwise add an upgrade step that sanitizes the stored row mods. Add a test that stores an injected value and renders the row CSS.
Validation details
-
Files reviewed: 4/4 changed files. The failure-direction visibility question stayed unchecked.
-
New PHPUnit file at HEAD, WordPress 7.1.4, PHP 8.3.36:
rm -f /var/www/html/wp-content/themes/repo; mkdir -p /tmp/r1-head && git clone -q /repo /tmp/r1-head/neve && git -C /tmp…printedOK (8 tests, 20 assertions)(run R11) -
Same tests with the pr-base source files:
rm -rf /tmp/r1-base; mkdir -p /tmp/r1-base && git clone -q /repo /tmp/r1-base/neve 2>/dev/null && cd /tmp/r1-base/neve &…printedFailures: 7(run R18) All seven are assertion failures on the changed behavior. -
Dynamic CSS probes at HEAD: `cd /workspace/checks/R2/probe; python3 - <<'EOF'
p='R2ProbeTest.php'
s=open(p).read()
s=s.rstrip()[:-1].rstrip()+'''p…
(run R20, exit 0)cd /workspace/checks/R3; set -o pipefail; ./run-cases.sh head /tmp/r1-head/neve case2 case3_red case3_invalid 2>&1 | tai…` (run R24, exit 0)
Untested areas
- The Neve Pro conditional-header Customizer save was not run. Its source is not in this repository.
- Failure direction: Visibility. Header and footer configure calls do not report a skipped style to the caller.
- Row text colors saved through the Customizer use
wp_filter_nohtml_kses. Their save path was not run. - Allowlisted icon and label keys reach HTML output. They were not checked.
🤖 Automated review · run code-review-agent_6aedb300e2ded7.54876491.
🤖 Review agent — review posted ✅ on 27949c8e · changes requested · 4 findings · 29 min
Run code-review-agent_6aedb300e2ded7.54876491 · trail
|
Review item F2/F6: |
There was a problem hiding this comment.
🟡 Changes requested
The row color and ability write fixes work, but values stored by Neve 4.2.15 to 4.2.18 and button appearance colors still print breakout CSS.
globals/sanitize-functions.php:284—security✓ Verified in the sandbox The theme's own Customizer also stores breakout CSS in the header button appearance settings.neve_sanitize_button_appearance()returns its input unchanged. It sanitizesbutton_base_style_setting,nav-icon_button_appearanceandheader_search_button_style. A savedbackgroundofrgba(1,2,3,1);}body{background:lime}/*prints--primarybtnbg: rgba(1,2,3,1);}body{background:lime}/*in the header CSS. This is the stored-color cause of #3310, which this PR closes, on another header setting. Run each color field throughneve_sanitize_colors()inneve_sanitize_button_appearance(). Also filter these colors when the CSS is built, so stored values are covered. Add a test that saves an injected appearance and renders the header CSS.
Validation details
- Files reviewed: 7/7 changed files. Narrowed input: Sources and the issue #3820 PHPStan history question stayed unchecked.
- Earlier body findings on
--rowbcolor,--color,--bgcolorand--overlaycolorare fixed. The row CSS test fails with the pr-base and 27949c8 source files:does not contain "background:lime"(run R14). - Default row colors print as before:
--rowbcolor: var(--nv-light-bg) | --color: var(--nv-text-color) | --bgcolor: var(--nv-site-bg)(runs R1 and R2, HEAD and pr-base). - A JSON-object key cannot break out in Chromium:
"bodyBg":"rgba(0, 0, 0, 0)"(run R5).
Untested areas
- Narrowed input: Sources. No captured request sends a non-empty invalid nested background color.
- Issue #3820 PHPStan history question. Its report is truncated, and CI runs PHPStan.
- Neve Pro save path. Its source is not in this repository.
- Component colors (navigation, search, cart, logo, HTML) print stored values raw. No writer that stores them raw was found.
- The
--bgimageURL quoting was not checked against WordPress core.
🤖 Automated review · run code-review-agent_6aedbd2a3bcd79.59038177.
🤖 Review agent — review posted ✅ on 1b42ce89 · changes requested · 5 findings · 39 min
Run code-review-agent_6aedbd2a3bcd79.59038177 · trail
There was a problem hiding this comment.
🟡 Changes requested
Stored values now print safely, but named row text colors still fail, and typeface, spacing and font family values still print breakout CSS.
globals/sanitize-functions.php:503—security✓ Verified in the sandbox Typeface settings still print breakout CSS.neve_sanitize_typography_control()checks only thatfontSize,lineHeightandletterSpacingare arrays. It keeps each device value raw. A Primary Menu typeface saved through the Customizer withfontSize.desktopset to0;}body{background:lime}/*prints--fontsize: 0;}body{background:lime}/*px;. This is the stored-value cause this PR fixes for colors, units and dimensions. Inneve_sanitize_typography_control(), keep each device value of the three fields only whenis_numeric()is true, and run eachsuffixthroughneve_sanitize_css_unit(). Also print these values through a numeric filter, so stored copies are covered. Add a test that stores the injected typeface and renders the CSS.header-footer-grid/Traits/Core.php:135—security✓ Verified in the sandbox Header component spacing still prints breakout CSS.sanitize_spacing_array()returns the saved array unchanged, and the directional printer appends each side raw. Savingbutton_base_component_paddingthrough the Customizer withtopset to5;}body{background:lime}/*prints--padding:5;}body{background:lime}/*px 5px 5px 5px;. Margin does the same. Search and SearchResponsive border width and radius, and the menu icon label margin, use the same writer and printer. Insanitize_spacing_array(), keep each side only whenis_numeric()is true, and run each unit throughneve_sanitize_css_unit(). AddMETA_FILTER => 'neve_sanitize_directional_css_rule'to each of these rules. Add a data-provider test that renders every member.inc/customizer/options/typography.php:141—security✓ Verified in the sandbox Font family settings still print breakout CSS. They are sanitized withsanitize_text_field(), which keeps;,{and}. The value is then printed unquoted. Savingneve_body_font_familyasArial;}body{background:lime}/*through the Customizer prints--bodyfontfamily: Arial;}body{background:lime}/*;. The headings font family settings use the same sanitizer. Reject a font family thatneve_closes_css_declaration()flags on save, including the ability write ininc/abilities/appearance_update.php:420. Check it again when the CSS is built, so stored copies are covered. Add a test that stores the injected family and renders the CSS withoutbackground:lime.
Validation details
- Files reviewed: 14/14 changed files. Unchecked: issue #3820 PHPStan history; button border radius (#3565);
get_suffix_responsive()consumers; Narrowed input: Rejected values, Base, Sources. - The earlier button appearance finding is fixed. Saved injected appearances render
--primarybtnbg: rgba(1,2,3,1);withlime_count=0(run R8). - The new button and ability tests pass at HEAD and fail with the pr-base source files. Logs are under
/workspace/checks/C1/. - No Customizer unit lies outside the new unit allowlist.
Untested areas
- Issue #3820 PHPStan history. Its report is cut, and CI runs PHPStan.
- Button border radius (#3565),
get_suffix_responsive()consumers, and Narrowed input: Rejected values, Base, Sources. The evidence did not settle them. - Neve Pro save path. Its source is not in this repository.
- Imported
transparentbutton colors become empty on the next save. No repository source emits them. - The variant pass did not settle these places, where the fixed cause may still reach:
inc/core/styles/css_vars.php:264-266,294-295— unverified: Font-family writers use sanitize_text_field() and the printer does not remove CSS delimiters from space-free family names. Confirming this path requires version-matched WordPress s…inc/core/styles/css_prop.php:393-425— unverified: Font-family writers use sanitize_text_field() and the printer does not remove CSS delimiters from space-free family names. Confirming this path requires version-matched WordPress s…
🤖 Automated review · run code-review-agent_6af37ea87bc4c4.75991116.
🤖 Review agent — review posted ✅ on 7b6e613f · changes requested · 5 findings · 52 min
Run code-review-agent_6af37ea87bc4c4.75991116 · trail
There was a problem hiding this comment.
🟡 Changes requested
The earlier findings are fixed, but spacing, typeface, font family and button appearance values still print breakout CSS or save invalid colors.
inc/core/styles/frontend.php:1040—security✓ Verified in the sandbox Two spacing rules still print breakout CSS. The globalneve_content_vspacingsetting has no sanitize callback, and its--c-vspacerule here has no filter. This commit gave its post and CPT siblingsneve_sanitize_directional_css_ruleat lines 1052 and 1072. Saving itstopside as5;}body{background:lime}/*through the Customizer printsbackground:lime. The blog card padding rule (neve_blog_content_padding) also prints a stored side raw, and pr-base's Customizer accepted that value. AddDynamic_Selector::META_FILTER => 'neve_sanitize_directional_css_rule'to both rules. Giveneve_content_vspacinga spacing sanitize callback. Add both mods to the stored-style test intests/test-neve-ability-style-mods.php.
Validation details
- Files reviewed: 24/24 changed files. Unchecked: issue #3820 PHPStan; Narrowed input: Sources; Optional setting off: Producer, Setting off, Setting unset, Non-default value, Override, Empty data, Stale data.
- The new tests pass at HEAD
cd /workspace/checks/C1/wt/neve && set -o pipefail; timeout 600 phpunit --do-not-cache-result --filter 'TestNeveAbilityS…(run R3, exit 0) and, except two preservation tests, fail with the pr-base sourcescd /workspace/checks/C1/wt/pb/neve && set -o pipefail; timeout 600 phpunit --do-not-cache-result --filter 'TestNeveAbili…(run R4, exit 0). - Default settings render the same CSS at HEAD
cd /workspace/checks/C2 && sed -i "s/Mods::get( 'neve_typeface_general', array() )/Mods::get( 'neve_typeface_general' )/…(run R8, exit 0) and pr-basecd /workspace/checks/C2/pb/neve && C2_OUT=/workspace/checks/C2/out C2_TAG=-pb phpunit --do-not-cache-result --filter 'C2…(run R9, exit 0). - Typography units in the control and defaults stay inside the new unit list.
Untested areas
- Issue #3820 PHPStan history. Its report is cut, and PHPStan was not run.
- The unchecked checklist questions above. The checks found no producer that breaks them.
- Cover overlay printing and archive widths. Their Customizer callbacks reject the payload.
- Neve Pro save paths. Their source is not in this repository.
Questions for the author
- Spacing sides stored as
''now print0instead of an empty value. Do supported layouts rely on blank spacing to keep default padding?
🤖 Automated review · run code-review-agent_6af392c56b8320.53082181.
🤖 Review agent — review posted ✅ on b3678277 · changes requested · 9 findings · 62 min
Run code-review-agent_6af392c56b8320.53082181 · trail
There was a problem hiding this comment.
🟡 Changes requested
The earlier findings are fixed, but stored post text transforms still print breakout CSS, and two new checks reject valid values.
inc/core/styles/frontend.php:182—security✓ Verified in the sandbox Stored archive and single-post text transforms still print breakout CSS. This rule passes its meta as a string, not an array.Css_Prop::transform()checksisset( $meta[ Dynamic_Selector::META_KEY ] ), which is false for a string, so the new allowlist is skipped. pr-base had no sanitize callback for these six typography settings, so it stored5;}body{background:lime}/*unchanged. With that value stored, HEAD prints--texttransform: 5;}body{background:lime}/*for all six selectors. This was already in the code the earlier review saw. Change the rule to'--texttransform' => [ Dynamic_Selector::META_KEY => $args['mod'] . '.textTransform' ]. Add a test that stores the payload inneve_archive_typography_post_titleand asserts the CSS has nobackground:lime.
Validation details
- Files reviewed: 13/13 files changed since the prior review. Unchecked: Update PHPStan and fix the reported issues; Button padding different when using EM unit; Optional setting off: Producer, Setting off, Setting unset, Non-default value, Override, Empty data, Stale data.
- The suite passes at HEAD in run R1:
OK (48 tests, 306 assertions). The seven new tests fail on the previous head in run R17. - The earlier spacing finding is fixed. Blog padding and content spacing now use the directional sanitizer.
- Default settings render equivalent CSS at HEAD and pr-base in run R5.
Untested areas
- Button padding different when using EM unit. The source trace found no unit loss, but it was not run.
- Update PHPStan and fix the reported issues. PHPStan and PHPCS were not run.
- The optional-setting questions above. The code is unchanged since the earlier review.
- Keys added through the ability allowlist filter, and container width writes that rely on the host schema check.
- Legacy blank spacing sides, and custom font names from Neve Pro or Orbit Fox.
🤖 Automated review · run code-review-agent_6af3a9628829a3.28192221.
🤖 Review agent — review posted ✅ on c35098f4 · changes requested · 3 findings · 49 min
Run code-review-agent_6af3a9628829a3.28192221 · trail
There was a problem hiding this comment.
🟡 Changes requested
The three earlier findings are fixed, but ability color writes still accept malformed gradients and replace the saved color.
Validation details
- Files reviewed: 6/6 files changed since the prior review. Unchecked: Update PHPStan and fix the reported issues; Button padding different when using EM unit; No option to remove border radius from button component; Visual regression on add to cart button of the single product page; the return checks of
transform_directional_prop(),neve_sanitize_colors(),Button::add_style(),Core::sanitize_spacing_array()andneve_is_css_function_color(); Narrowed input; Optional setting off. set -e; W=/workspace/checks/R1; rm -rf $W/head $W/prev; mkdir -p $W/head/neve $W/prev/neve; cd /repo; git archive HEAD |…printedOK (50 tests, 319 assertions)(run R5)- With the previous head's sources, the new tests fail:
W=/workspace/checks/R1; cd $W/prev/neve && set -o pipefail; timeout 900 phpunit --do-not-cache-result --filter 'TestNeve…printedFailures: 4(run R6) - The archive text transform fix is confirmed. The stored payload no longer prints
background:lime.
Untested areas
- PHPStan and PHPCS were not run. CI owns them.
- The unchecked questions above. Their code is unchanged since the prior review.
- Standalone font sizes, aspect ratio, radius, palette and cover output. No old producer of breakout values was found.
- The new navigation
text_buttonassertion is inconclusive against pr-base. - The variant pass did not settle these places, where the fixed cause may still reach:
header-footer-grid/Core/Components/Logo.php:585-590— unverified: Standalone font-size keys bypass output validation. Configured sanitizers constrain input (Logo.php:490; Search.php:175; SearchResponsive.php:343; header-footer-grid/Traits/Core.ph…header-footer-grid/Core/Components/Search.php:387-390— unverified: Standalone font-size keys bypass output validation. Configured sanitizers constrain input (Logo.php:490; Search.php:175; SearchResponsive.php:343; header-footer-grid/Traits/Core.ph…header-footer-grid/Core/Components/SearchResponsive.php:567-571— unverified: Standalone font-size keys bypass output validation. Configured sanitizers constrain input (Logo.php:490; Search.php:175; SearchResponsive.php:343; header-footer-grid/Traits/Core.ph…inc/core/styles/frontend.php:228-235,272-276,828-836— unverified: Aspect-ratio and radius filters interpolate directly. Project callbacks constrain ordinary inputs (inc/customizer/options/layout_blog.php:501-503,879; inc/customizer/options/layout…inc/core/dynamic_css.php:197-222— unverified: Palette and cover properties retain raw output paths; no complete pr-base producer-to-breakout trace was established.inc/core/styles/frontend.php:915-1000— unverified: Palette and cover properties retain raw output paths; no complete pr-base producer-to-breakout trace was established.
🤖 Automated review · run code-review-agent_6af3b85234dda1.07313054.
🤖 Review agent — review posted ✅ on cd654f7d · changes requested · 1 finding · 14 min
Run code-review-agent_6af3b85234dda1.07313054 · trail
There was a problem hiding this comment.
🟡 Changes requested
The malformed gradient fix works, but standalone function colors, var() fallbacks, hex button colors and stored row colors still accept invalid values.
inc/abilities/appearance_update.php:591—correctnessAppearance_Updateaccepts hex button colors of any length from 3 to 8 digits. The check/^#[0-9a-fA-F]{3,8}$/passes#12345and#1234567, which are not CSS colors. Sobuttons.primary.backgroundset to#12345replaces the saved button color, and the browser drops it. The PR states that invalid values are rejected and existing settings are kept. Accept only 3, 4, 6 or 8 digits, as the new gradient stop check atglobals/sanitize-functions.php:156does. Add a button case totests/test-neve-ability-style-mods.phpthat sends#12345and asserts the kept color.globals/sanitize-functions.php:36—correctness✓ Verified in the sandbox Avar()color with a broken fallback still replaces a saved color. This assumes the caller names a variable the page does not define.neve_is_css_var()checks the fallback only for allowed characters, sovar(--c5-missing,rgb(foo))passes. With#ff0000saved,Site_Set_Theme_Modstores it, and Chromium then treats the color as invalid. The new gradient stops reuse this check, solinear-gradient(var(--c5-missing,rgb(foo)),#fff)is stored too. Validate the fallback with the same rules as a top-level color, recursively. Add both values to the invalid color cases intests/test-neve-sanitization.php.
Validation details
- Files reviewed: 3/3 files changed since the prior review. Unchecked: Update PHPStan and fix the reported issues; Button padding different when using EM unit; No option to remove border radius from button component; Visual regression on add to cart button of the single product page; the return checks of
transform_directional_prop(),format_font_family_value(),neve_sanitize_colors(),Button::add_style()andCore::sanitize_spacing_array(); Narrowed input; Optional setting off. - The changed tests pass at HEAD:
cd /workspace/checks/C3 && rm -rf head prev base && mkdir -p head/neve prev/neve base/neve && cd /repo && git archive HE…printedOK (42 tests, 354 assertions)(run R3) - With the previous head's sources, they fail:
cd /workspace/checks/C3 && grep -n 'invalid_colors' /repo/tests/test-neve-ability-style-mods.php | head; cd abprev/neve …printedFailures: 2(run R5) - WordPress core gradient presets and the picker default are kept
rg -n -A 85 -B 3 '"gradients"' /var/www/html/wp-includes/theme.json; rg -n '^\$wp_version' /var/www/html/wp-includes/ver…(run R7, exit 0). - Question:
CONTRIBUTING.mdputs unit tests intests/php/unit, but the suite usestests/test-*.php. Is that section outdated?
Untested areas
- PHPStan and PHPCS were not run. CI owns them.
- The unchecked questions above were not rechecked. Their code is unchanged since the prior review.
- Gradient color hints and line breaks are now rejected. No producer emits them, so lost saved values stay unverified.
- Standalone font sizes, aspect ratio, radius, palette, cover output and blank spacing sides were not rechecked.
- PHPUnit in
/repostops on a missingCss_Varstrait. The runs used archive copies. - The variant pass did not settle these places, where the fixed cause may still reach:
inc/core/styles/css_prop.php:117-121— unverified: The ordinary hex branch delegates to WordPress sanitize_hex_color(). Only a declaration stub was found (vendor/php-stubs/wordpress-stubs/wordpress-stubs.php:110745-110758), not ver…
🤖 Automated review · run code-review-agent_6af3c67654d173.12104135.
🤖 Review agent — review posted ✅ on 459b4c12 · changes requested · 5 findings · 26 min
Run code-review-agent_6af3c67654d173.12104135 · trail
There was a problem hiding this comment.
🟡 Changes requested
The earlier findings are fixed, but mixed-unit rgba() colors and unsupported color syntax still replace a saved color.
Validation details
- Files reviewed: 6/6 files changed since the prior review. Unchecked: Update PHPStan and fix the reported issues; Narrowed input; Optional setting off; the return checks of
transform_directional_prop(),format_font_family_value(),Button::add_style()andCore::sanitize_spacing_array(); Button padding different when using EM unit; No option to remove border radius from button component; Visual regression on add to cart button of the single product page. - The changed tests pass at HEAD:
cd /workspace/checks/C1/head/neve && set -o pipefail; timeout 300 phpunit --do-not-cache-result --filter 'TestNeveAbilit…(run R3, exit 0) - With the previous head's sources, ten of them fail:
cd /workspace/checks/C1/abpr/neve && set -o pipefail; timeout 300 phpunit --do-not-cache-result --filter 'TestNeveAbilit…(run R4, exit 0) - The hex button and
var()fallback fixes are covered by those failing tests. - Breakout probes are rejected: `cat > /workspace/checks/C1/test-c1-probe.php <<'EOF'
Untested areas
- The unchecked questions above were not rechecked. The narrowed-input check timed out. - `var()` fallbacks such as `inherit` or `none` are now rejected. No producer was found. - PHPStan, PHPCS and PHPUnit in `/repo` were not run. Runs used archive copies. - The variant pass did not settle these places, where the fixed cause may still reach: - `header-footer-grid/Core/Builder/Header.php:459-490` — unverified: Global-header background/overlay custom properties still print stored values without a color filter. Current Customizer writes use neve_sanitize_background() at Header.php:354; an … - `inc/core/styles/css_prop.php:272-274` — unverified: Global-header background/overlay custom properties still print stored values without a color filter. Current Customizer writes use neve_sanitize_background() at Header.php:354; an … - `inc/core/dynamic_css.php:125-131,149-152,181-222` — unverified: Root, custom, Elementor and light/dark palettes interpolate stored colors directly. Current palette sanitizers guard writes at inc/customizer/options/colors_background.php:151-158,… - `inc/compatibility/elementor.php:115-131,380-391` — unverified: Root, custom, Elementor and light/dark palettes interpolate stored colors directly. Current palette sanitizers guard writes at inc/customizer/options/colors_background.php:151-158,… - `header-footer-grid/Core/Components/PaletteSwitch.php:202-246,284-300` — unverified: Root, custom, Elementor and light/dark palettes interpolate stored colors directly. Current palette sanitizers guard writes at inc/customizer/options/colors_background.php:151-158,… - `header-footer-grid/Core/Components/Nav.php:511-525` — unverified: Navigation and cover custom properties lack output color validation. Their complete write/import paths were not traced, so declaration-breaking stored-state reachability remains un… - `inc/core/styles/frontend.php:941-992` — unverified: Navigation and cover custom properties lack output color validation. Their complete write/import paths were not traced, so declaration-breaking stored-state reachability remains un… - not reached: Full source/guard traces for sibling custom-property colors in CartIcon.php, EddCartIcon.php, CustomHtml.php, Logo.php, NavFooter.php, SecondNav.php, Search.php and SearchResponsiv… - and 1 more| if ( 'rgba' === $mode ) { | ||
| return neve_sanitize_rgba( $value ); | ||
| $component = '[+-]?(?:\d+(?:\.\d*)?|\.\d+)%?'; | ||
| if ( ! preg_match( '/^rgba\(\s*' . $component . '(?:\s*,\s*' . $component . '){2,3}\s*\)/', trim( $value ), $match ) ) { | ||
| return ''; | ||
| } | ||
|
|
||
| return neve_sanitize_rgba( $match[0] ); |
There was a problem hiding this comment.
correctness ✓ Verified in the sandbox A mixed-unit rgba() color is saved as a broken value. The strict function check now rejects rgba(255, 0%, 0, 1), so neve_sanitize_colors() reaches this legacy branch. Its component regex allows % on any channel. neve_sanitize_rgba() then returns rgba(255,0,rgba(0,0,0,0),rgba(0,0,0,0)). With #123456 saved, Site_Set_Theme_Mod stores that string, and Chromium rejects it. Return the neve_sanitize_rgba() result only when neve_is_css_function_color() accepts it, and return '' otherwise. Add rgba(255, 0%, 0, 1) to the loop in test_site_set_theme_mod_rejects_malformed_function_color and to the invalid function-color cases in tests/test-neve-sanitization.php.
| $space = '(?:srgb|srgb-linear|display-p3|a98-rgb|prophoto-rgb|rec2020|xyz|xyz-d50|xyz-d65|--[a-z0-9_-]+)'; | ||
|
|
||
| return (bool) preg_match( '/^\s*' . $space . $modern_components . '$/i', $function['body'] ); | ||
| case 'device-cmyk': | ||
| return (bool) preg_match( '/^\s*' . $none_component . '(?:\s+' . $none_component . '){3}' . $optional_alpha . '\s*$/i', $function['body'] ); |
There was a problem hiding this comment.
correctness ✓ Verified in the sandbox The color grammar now accepts color syntax that Chromium does not render. device-cmyk(), color() with a --custom space, and in --custom gradient interpolation (line 276) all pass. With #123456 saved, Site_Set_Theme_Mod stores device-cmyk(0 1 1 0) and the three other forms. Chromium 156 reports CSS.supports false for all four, so the saved color is lost. Remove the device-cmyk case and the --[a-z0-9_-]+ alternatives at lines 276 and 427. Move the device-cmyk(0 1 1 0) gradient from the valid to the invalid cases in tests/test-neve-sanitization.php, and add color(--custom 1 0 0) there.
| 'var(--c5-missing,rgb(foo))', | ||
| 'var(--x, rgba(1,2,3,1)junk)', | ||
| 'var(--x, rgba(1,2,3,1);}body{background:lime}/*)', | ||
| 'var(--x, rgba(1,2,3,1)/*(*/);}body{background:lime}/*)', | ||
| 'var(--x, rgba(1,2,3,1)</style><script>alert(1)</script>)', |
There was a problem hiding this comment.
tests No case covers the new keyword gate in neve_is_css_var(). A keyword fallback now passes only when neve_sanitize_row_text_color() accepts it. The invalid list has no bare-keyword fallback, so no case checks that gate. Add var(--x, notacolor) to these invalid cases.
| if ( neve_is_css_var( $fallback ) || (bool) preg_match( '/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i', $fallback ) ) { | ||
| return true; | ||
| } | ||
|
|
||
| if ( neve_is_css_function_color( $fallback ) ) { | ||
| return true; | ||
| } | ||
|
|
||
| return (bool) preg_match( '/^[a-z]+(?:-[a-z]+)*$/i', $fallback ) | ||
| && '' !== neve_sanitize_row_text_color( $fallback ); |
There was a problem hiding this comment.
bloat These fallback checks repeat neve_is_css_gradient_color() at lines 452-464. Both accept a hex color, a var(), a function color or a named keyword, and every check is pure. $fallback is already trimmed, and neve_is_css_function_color() only trims and calls the same function. Replace lines 74-83 with return neve_is_css_gradient_color( $fallback );. Keep the neve_closes_css_declaration() check before it.
| $direct = 'conic' === strtolower( $type ) | ||
| ? '(?:' . $zero . '|' . $number . '(?:%|deg|grad|rad|turn))' | ||
| : $patterns['simple_length']; |
There was a problem hiding this comment.
bloat This $direct pattern copies the one in neve_is_css_gradient_dimension() at lines 603-605, character for character. A later unit fix can reach one copy and miss the other. Add neve_css_gradient_direct_pattern( string $type ): string that returns the conic or linear pattern. Call it in both functions. Drop the local $zero, and keep $number in neve_css_gradient_math_operand_type() for its plain number check. Keep every result unchanged.
|
💂♂️ PR Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id> |
Closed without merge.