Skip to content

FIX Include settings that change output in MathObfuscation, NegationTrap, SelectiveText and Zalgo converter identifiers - #3288

Merged
Roman Lutz (romanlutz) merged 4 commits into
microsoft:mainfrom
ShivamSharma43:fix/text-converter-identifiers
Oct 18, 2026
Merged

Roman Lutz (romanlutz) merged 4 commits into
microsoft:mainfrom
ShivamSharma43:fix/text-converter-identifiers

Conversation

@ShivamSharma43

Copy link
Copy Markdown
Contributor

Description

Fixes #3287.

Four text converters left settings that change their output out of their identifiers, so differently configured instances had the same hash and default registry name. For example, NegationTrapConverter(wrong_value="1234") and NegationTrapConverter(wrong_value="hunter2") collided, and registering the second one raised ValueError: Instance 'NegationTrapConverter::89a3d225' already exists.

Each converter now adds the missing settings:

  • MathObfuscationConverter: hint_hash and suffix_hash, SHA-256 prefixes of the resolved hint and suffix, the same way AddTextImageConverter identifies text_to_add. An explicit default hint or suffix keeps the default identity, and "" (disabled) gets its own.
  • NegationTrapConverter: a new _build_identifier() with wrong_value and trap_template_hash. Before this it had no params at all.
  • SelectiveTextConverter: word_separator, only for word-level strategies, because character-level and token strategies never split on it. Their hashes are unchanged.
  • ZalgoConverter: seed, like the other seeded converters. None params are not hashed, so unseeded Zalgo converters keep their hash.

Conversion behavior is unchanged. The default hashes of MathObfuscationConverter, NegationTrapConverter and word-level SelectiveTextConverter change once, because they now include these settings. Nothing in the repository pins these hashes.

Tests and Documentation

  • New identifier tests in the four converter test files. Each checks that a different setting gets a different hash and that both instances register in ConverterRegistry, and that equal settings keep the same hash. SelectiveTextConverter also checks that character-level strategies ignore word_separator, and ZalgoConverter that an unseeded converter has no seed param. On main, 10 of the new tests fail. With this change, all of them pass.
  • pytest tests/unit/converter tests/unit/registry tests/unit/backend/test_converter_service.py: 3734 passed, 38 skipped.
  • ruff check, ruff format and ty check pass on the changed files. git diff --check is clean.
  • No documentation changes. JupyText not run, since the converter docs do not use identifiers.

🤖 Generated with Claude Code

…rap, SelectiveText and Zalgo converter identifiers

MathObfuscationConverter now identifies hint and suffix, NegationTrapConverter
gets an identifier with wrong_value and the trap template, SelectiveTextConverter
adds word_separator for word-level strategies and ZalgoConverter adds seed.

Fixes microsoft#3287

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 17, 2026 14:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ManoharPaturi

Copy link
Copy Markdown
Contributor

The identifier coverage across these four converters looks very thorough. Gating word separator in SelectiveTextConverter only when using word level selection strategies avoids invalidating hashes for character level transformations where the separator has no effect. Similarly, omitting seed when None preserves the unseeded hash for ZalgoConverter while distinguishing seeded runs. Checked registration against ConverterRegistry and the instance collision tests all pass.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0e3986dd-0311-4a86-a594-8e622d240d52
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0e3986dd-0311-4a86-a594-8e622d240d52
@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Oct 18, 2026
Merged via the queue into microsoft:main with commit 991d058 Oct 18, 2026
64 checks passed
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.

BUG: MathObfuscation, NegationTrap, SelectiveText and Zalgo converter identifiers ignore settings that change output

4 participants