Managesieve: preserve an explicitly-selected i;ascii-casemap comparator (#9981) - #10266
Open
MiMoHo wants to merge 1 commit into
Open
Managesieve: preserve an explicitly-selected i;ascii-casemap comparator (#9981)#10266MiMoHo wants to merge 1 commit into
MiMoHo wants to merge 1 commit into
Conversation
…or (roundcube#9981) When a user explicitly selected the "i;ascii-casemap" comparator for a filter test, it was dropped from the generated script because it equals the RFC default and add_comparator() skipped emitting it. The explicit choice was therefore lost, and scripts that contained :comparator "i;ascii-casemap" did not survive a load/save round-trip. The comparator is only populated when it was set explicitly - the form leaves it empty for the "default" option, and the parser only sets it from an explicit :comparator token - so emitting it whenever present is safe and does not add a redundant :comparator to ordinary rules. The parser fixture is updated to reflect the now-preserved comparator. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
MiMoHo
force-pushed
the
pr-managesieve-casemap-9981
branch
from
July 16, 2026 08:13
ba02adf to
f31c058
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a user explicitly selects the
i;ascii-casemapcomparator for a filter test, the choice is silently dropped from the generated Sieve script. The saved rule therefore does not reflect the explicit selection, and re-parsing/re-saving the script loses it entirely (round-trip loss). See #9981.Root cause
plugins/managesieve/lib/Roundcube/rcube_sieve_script.php,add_comparator()(previously ~line 1056):Because
i;ascii-casemapis the RFC 5228 default comparator, the code unconditionally suppressed it on output. However, both the parser (test_tokens()) and the engine (rcube_sieve_engine.php:1015, only setscomparatorwhen the user picked one) populate thecomparatorkey only on an explicit selection — an unset comparator leaves the key empty and is already short-circuited by theempty()guard at the top ofadd_comparator(). So the presence ofcomparator == 'i;ascii-casemap'unambiguously means "the user chose it", yet it was still discarded.Fix
Emit the comparator whenever it is present. The existing
empty()guard still means the default (unset) case emits nothing, so scripts without an explicit comparator are unchanged. Behavior fori;octetandi;ascii-numericis unchanged, andi;ascii-casemapcontinues to be excluded from therequire/extensions list (it is a built-in comparator requiring no capability).Testing
Added two focused tests in
plugins/managesieve/tests/ManagesieveScriptTest.php:test_explicit_ascii_casemap_comparator— parses a rule with an explicit:comparator "i;ascii-casemap", assertsas_text()emits it, and asserts it survives a re-parse round-trip. Fails on current master, passes after the fix.test_default_comparator_not_emitted— asserts that a rule with no explicit comparator emits no:comparatortoken (guards against regression).The existing
parser/parser.outfixture was updated to reflect the corrected (non-lossy) output for its expliciti;ascii-casemapcase. FullManagesieveScriptTestsuite passes (35 tests). phpstan level 4 on the changed file reports no errors.Fixes #9981