jmikola / geojson

GeoJSON implementation for PHP
MIT License
295 stars 47 forks source link

Invalid properties #46

Closed Norda-AD closed 5 months ago

Norda-AD commented 5 months ago

According to the RFC 7946, the properties in a Feature objet must be an array or a null value.

When I provide another value (for instance a string), the value is accepted as-is when using GeoJson::jsonUnserialize. I was expecting to receive an GeoJson\Exception\UnserializationException exception. Is this sensible to you ?

Norda-AD commented 5 months ago

I am not sure I understand your answer.

Do you mean it makes no sense to throw the UnserializationException when the properties are not properly formatted? Or do you mean it makes no sense to throw the UnserializationException when there is GeoJson\Exception\UnserializationException ?

If it’s the later, I think my explanation was lousy. I will change my issue.

Regards

Le 2 mai 2024 à 11:04, Vlad Yarysh @.***> a écrit :

Nope, I just changed Unserialization Exception from global namespace to the library's

— Reply to this email directly, view it on GitHubhttps://github.com/jmikola/geojson/issues/46#issuecomment-2090760617, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A6UROGTX72J5JLWPZZYH5OLZAJIYVAVCNFSM6AAAAABHD4UZNGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJQG43DANRRG4. You are receiving this because you authored the thread.Message ID: @.***>

gabplch commented 5 months ago

Sorry, made wrong answer

On Thu, 2 May 2024 at 18:12, Norda-AD @.***> wrote:

I am not sure I understand your answer.

Do you mean it makes no sense to throw the UnserializationException when the properties are not properly formatted? Or do you mean it makes no sense to throw the UnserializationException when there is GeoJson\Exception\UnserializationException ?

If it’s the later, I think my explanation was lousy. I will change my issue.

Regards

Le 2 mai 2024 à 11:04, Vlad Yarysh @.***> a écrit :

ATTENTION: Courriel externe / external email

Nope, I just changed Unserialization Exception from global namespace to the library's

— Reply to this email directly, view it on GitHub< https://github.com/jmikola/geojson/issues/46#issuecomment-2090760617>, or unsubscribe< https://github.com/notifications/unsubscribe-auth/A6UROGTX72J5JLWPZZYH5OLZAJIYVAVCNFSM6AAAAABHD4UZNGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJQG43DANRRG4>.

You are receiving this because you authored the thread.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/jmikola/geojson/issues/46#issuecomment-2090776614, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASYFLJPTGYYZYDPI2LT2XHLZAJJVHAVCNFSM6AAAAABHD4UZNGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJQG43TMNRRGQ . You are receiving this because you commented.Message ID: @.***>

jmikola commented 5 months ago

@Norda-AD: Can you share a failing test case or MRE?

The existing GeoJson::jsonUnserialize method does validate that geometry and properties are either arrays or objects, so I would expect an exception in this case. See: https://github.com/jmikola/geojson/blob/1.2.0/src/GeoJson.php#L117

Norda-AD commented 5 months ago

Sorry for the trouble. Indeed, it triggers the error. I don't know why I didn't have that error before. Maybe it's lost in the many layers of my application.

Thank you for your time.