-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect behavior of PropertyAccessor when dynamic property contains dot #41845
Comments
You can try using the Status: Reviewed Or you can try casting an object to an array instead? And use an index-path. |
Is it possible to do it, when I'm using Serializer directly? $this->json( (object) $myArray) ); |
The Or we could change the PropertyPath parsing logic to handle special cases like But before we move forward with this idea I think it's best to hear from others 😄 technically it's possible 👍🏼 |
Hey, thanks for your report! |
Could I get a reply or should I close this? |
Hey, I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen! |
Could we open it once again ? I guess if no one will try to fix it, ill do it at my own. |
Hey, thanks for your report! |
Friendly ping? Should this still be open? I will close if I don't hear anything. |
Hey, I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen! |
…oulain) This PR was merged into the 6.3 branch. Discussion ---------- [PropertyAccess] Allow escaping in PropertyPath | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #41845 | License | MIT | Doc PR | TODO symfony/symfony-docs#... I'm not sure if it can be considered a feature or a fix. Currently there is no way to escape `.` and `[` when using `PropertyPath`. It can cause issue when we want to access a "property" containing a dot (for instance a key in an array). I tried to modify the regexp as little as possible and to handle (really) edge cases such as double escaping. Initially I had the issue in some Behat tests where I needed to evaluate some paths in a big JSON file (OpenAPI documentation). Some keys contain dots and I cannot test the JSON node when it's the case. Commits ------- d534287 feat(property-access): allow escaping in PropertyPath
Symfony version(s) affected: 5.2.0
Description
Attempting to serialize an array which casted to object, if any of these properties contains "." (dot)
PropertyAccess resolvePath(getPropertyPath) behaves weird
symfony/src/Symfony/Component/PropertyAccess/PropertyPath.php
Lines 88 to 90 in 0758e59
How to reproduce
Exception will be thrown, which we can handle by using
disableExceptionOnInvalidPropertyPath
if we are using PropertyAccessor directly,
but not in case when we are using ObjectNormalizer / Serializer e.g $this->json($object)
propertyPath
resolve it as two elements
and of course an attempt to access the object with any of these properties
e.g
makes no sense, cause $zval does not know anything about these properties, but knows about
No. of Rows
Possible Solution
Process this case correctly :D
Additional context
The example above was reproduced with simple test command in CLI environment
The text was updated successfully, but these errors were encountered: