Repository navigation
Keep / # ( ) : in imported street addresses - #292
Closed
Marvin-Magmodules wants to merge 3 commits into
Closed
Marvin-Magmodules wants to merge 3 commits into
Marvin-Magmodules wants to merge 3 commits into
Conversation
Release 1.24.3
PATTERN_STREET strips every character outside its allowlist, so a street
like "Examplestreet 55/3" was stored as "Examplestreet 553". That is not
only a missing character: the house number itself changes into a
different, undeliverable one. In the separate-house-number path the ext
"/ 3" collapsed to "3" the same way.
The allowlist was copied from Magento\Customer\Model\Validator\Street so
that addressRepository->save() would not reject imported addresses, but
that validator rejects none of these characters - its character class
closes early on the "[] sequence, and isValidStreet() returns true
whenever the pattern fails to match. Verified against the real
customer_address/save composite validator: / # + : * ? ! @ $ % ^ = ~ ; |
\ { } < > ( ) are all accepted.
Allow the punctuation that legitimately appears in addresses: / for
house-number separators (AT, PL, CZ, IT), # for unit numbers, ( ) for
parenthetical additions and : for box numbers. Angle brackets and the
rest stay stripped.
The street pattern decides what reaches the stored address, and the ways it can go wrong are invisible in a diff: a dropped separator turns "55/3" into "553", a different house. That belongs in tests that run on every change, not in a reviewer's head. The module had no PHPUnit setup at all, so this brings over the arrangement already used in magento2-bol and magento2-eboekhouden: phpunit.xml.dist, a bootstrap that resolves the surrounding Magento install, and test-only dependencies in Test/composer.json - kept out of the module's own composer.json so the shipped package stays dependency-free, and installed separately because Magento's root autoloader excludes **/Test/** from its classmap and breaks the PHPUnit copy shipped with Magento. AddressHandlerTest covers getStreet() from both sides: the punctuation that carries address meaning survives (/ # ( ) :) across separate-house-number and combined-address-line paths and all three street_lines foldings, and everything outside the allowlist is still stripped, so widening it cannot quietly become an open door. Against the old pattern 9 of the 15 cases fail; the 5 stripping cases pass either way, which is the point of keeping both. What a unit test cannot settle is the reason the allowlist was narrow in the first place: the assumption that addressRepository->save() would reject these characters. Only a real import does, so the order import matrix gains one case - order in with "55/3", order out with "Examplestreet 55/3" on both addresses, and an explicit assertion that "553" is nowhere in it. buildOrderData gains street, houseNumber and houseNumberExt overrides, and OrderViewPage gains address getters that keep the line breaks so a street split across the wrong lines shows up in the assertion diff. /Test was already export-ignored; phpunit.xml.dist sits at the root and is added to .gitattributes so it does not ship with the package either.
Marvin-Magmodules
force-pushed
the
fix/street-sanitize-allowlist
branch
from
September 22, 2026 08:42
3155942 to
66a3d52
Compare
Member
Author
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.
PATTERN_STREETstrips every character outside its allowlist, so an imported street likeExamplestreet 55/3was stored asExamplestreet 553. That is not just a missing character — the house number itself becomes a different, undeliverable one. In the separate-house-number path the ext/ 3collapsed to3the same way.The allowlist was copied from
Magento\Customer\Model\Validator\StreetsoaddressRepository->save()would not reject imported addresses, but that validator rejects none of these characters: its character class closes early on the"[]sequence, andisValidStreet()returns true whenever the pattern fails to match. An E2E import confirms it — the order is created and the address is stored asExamplestreet/55/3.Allow the punctuation that legitimately appears in addresses:
/for house-number separators (AT, PL, CZ, IT),#for unit numbers,( )for parenthetical additions,:for box numbers. Angle brackets and the rest stay stripped.The second commit adds the tests: a PHPUnit suite on
getStreet()(15 cases, 9 of them fail against the old pattern) plus one case in the order import E2E matrix. The module had no PHPUnit setup, so this brings over the arrangement from magento2-bol/magento2-eboekhouden —phpunit.xml.dist, a bootstrap,Test/composer.json, and aphpunit.ymlworkflow on 2.4.7/2.4.8-p4/2.4.9. Both are export-ignored, so nothing extra ships in the package.