Repository navigation
Fix text() alphabet drawing characters outside the alphabet - #147
Open
Chirag6722 wants to merge 1 commit into
Open
Chirag6722 wants to merge 1 commit into
Chirag6722 wants to merge 1 commit into
Conversation
An alphabet is an empty category list plus the alphabet's characters. data() of an empty std::vector can be null, and the engine reads a null category list as no restriction, so the alphabet was not enforced. Pass a non-null pointer for an empty list. Fixes hegeldev#146
This branch has not been deployed
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.
Fixes #146.
text()builds an alphabet as an empty category list plusinclude_characters.string_generator_textpassedcategories.data(), anddata()of an emptystd::vectorcan be null (it is with libstdc++). The C ABI documents a nullcategoriesas "no restriction" and a non-null empty list as an empty set, so the alphabet was not enforced and characters outside it were drawn.The fix passes a non-null pointer when a category list is present but empty.
exclude_categoriesgoes through the same helper so both lists follow the documented contract.Test.
Formats.AlphabetRestrictsCharactersdrawstext()with the alphabet from the issue and checks that every character is in it. The existingDrawAlldraw oftext({.alphabet = "abc"})discards the value, so it could not catch this. Onmainthe new test fails (it drew"0"from"ab ~.-_%"); with the fix it passes.Checked locally (Ubuntu 22.04 under WSL, GCC 11.4, CMake 4.x): the full suite passes, 436/436.
clang-format --dry-run -Werroris clean on the changed files. I did not runcheck-tidyor the coverage gate locally.