XWIKI-23771: AWM: Numeric field accepts invalid characters, causing server error on edit#5830
Open
Sereza5 wants to merge 9 commits into
Open
XWIKI-23771: AWM: Numeric field accepts invalid characters, causing server error on edit#5830Sereza5 wants to merge 9 commits into
Sereza5 wants to merge 9 commits into
Conversation
…erver error on edit * Added the proper type to the input * Added an exception message that's straightforward
…erver error on edit * Added tests
…erver error on edit * Cleared up the checkstyle suppress
…erver error on edit * Fixed NumberClassTest for the new localized exception message
…erver error on edit * Reuse ClassSheetPage.clickTemplateLink() instead of a new page-object method
…erver error on edit * Fixed unwanted change
…erver error on edit * Updated an incorrect translation value that ended in an unexpected double dot at the end with wrapping.
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.
Jira URL
https://jira.xwiki.org/browse/XWIKI-23771
Changes
Description
<input type="number">instead of a plain text input, so browsers reject non-numeric input before the form is even submitted.NumberFormatException-derived message inNumberClass.fromString()to a user-friendlyXWikiExceptionmessageNumberClassFieldITClarifications
type="number"change only prevents obviously invalid characters; it doesn't stop values that are valid HTML5 numbers but still overflow the configured number type (e.g. a huge integer for alongfield). Those still reach the server, which is why thefromString()message fix is needed in addition to the input type change.ApplicationClassEditPage.addFieldAndEditTemplate()was added as a page-object helper for the new test; it locates the class template link via itshref(not its translated link text) sinceXWiki.ClassSheetnames the template document<ClassName>Templateand the template provider<ClassName>TemplateProvider(the latter is explicitly excluded from the selector).NumberClassTest(existing unit test) was updated to mockContextualLocalizationManagerand match the new exception message format, since the previous assertions relied on the old raw message.Screenshots & Video
I tried making a skill with claude code to generate this comparison table directly from a test instance. Feel free to let me know if anything important is missing from this output. I'll test it on a few more PRs (and probably adjust it) before sharing it with the community. Without a skill or memory, it's quite expensive/long to obtain this result.
Executed Tests
mvn test -Dtest=NumberClassTestinxwiki-platform-core/xwiki-platform-oldcorepassesmvn test -Dtest='*ClassTest'inxwiki-platform-core/xwiki-platform-oldcorepassesmvn install(checkstyle included) inxwiki-platform-core/xwiki-platform-oldcorepasses without violationsNumberClassFieldITDocker functional test (xwiki-platform-appwithinminutes-test-docker)mvn clean verify -Dit.test=NumberClassFieldITpassesExpected merging strategy