Skip to content

Only accept the cookie values written by the toggle action - #8

Open
loevgaard wants to merge 1 commit into
masterfrom
fix/strict-cookie-parsing
Open

Only accept the cookie values written by the toggle action#8
loevgaard wants to merge 1 commit into
masterfrom
fix/strict-cookie-parsing

Conversation

@loevgaard

Copy link
Copy Markdown
Member

CookieBasedVatContext did (bool) $cookie, so every non-empty value except '0' meant "display with VAT" — including 'false', which reads as the exact opposite of what it does.

The toggle action only ever writes '1' or '0', so this matches those two explicitly and throws NoVatContextException for anything else. That is the meaningful part: a value the plugin did not write is now "no context", so the composite context falls through to the next context (ending at the configured display_with_vat default) instead of interpreting whatever happened to be in the cookie.

Tests cover '', 'false', 'true' and an arbitrary string. The two existing tests were renamed from ..._is_truthy / ..._is_falsy to ..._is_one / ..._is_zero since truthiness is no longer what is being tested.

Addresses the third bug in #5.

https://claude.ai/code/session_01P9NzuVPQGvaVR97HZFq98a

Casting the cookie to bool meant every non-empty value except '0' was read as
'display with VAT', so a stray or hand edited cookie like 'false' silently
turned VAT display on.

Match '1' and '0' explicitly and throw NoVatContextException for anything else.
The composite context then falls through to the next context, which ends at the
configured default, instead of interpreting an arbitrary value.

Claude-Session: https://claude.ai/code/session_01P9NzuVPQGvaVR97HZFq98a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant