Skip to content
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

Convert string coordinates to floats, or raise an error #218

Merged
merged 3 commits into from
Sep 5, 2024

Conversation

s3cur3
Copy link
Contributor

@s3cur3 s3cur3 commented Aug 30, 2024

This fixes an issue where we were silently accepting non-numeric coordinates in the GeoJSON decoder, such that you could wind up doing things like decoding a point like %Geo.Point{coordinates: {"100.0", "-10.0"}}. This would obviously not have gone well for you later in your processing pipeline.

The fix here, suggested by @LostKobrakai, is to convert those strings to numbers where we can do so unambiguously. While such inputs are clearly invalid, it's easy enough to handle them in the way that the user was hoping that we should probably just do it. In cases where there's any ambiguity at all, we raise an ArgumentError.

Resolves #175

s3cur3 added 3 commits August 30, 2024 18:22
This fixes an issue where we were silently accepting non-numeric coordinates in the GeoJSON decoder, such that you could wind up doing things like decoding a point like `%Geo.Point{coordinates: {"100.0", "-10.0"}}`. This would obviously not have gone well for you later in your processing pipeline.

The fix here, suggested by @LostKobrakai, is to convert those strings to numbers where we can do so unambiguously. While such inputs are clearly invalid, it's easy enough to handle them in the way that the user was hoping that we should probably just do it. In cases where there's any ambiguity at all, we raise an ArgumentError.

Resolves #175
Copy link

@kyleVsteger kyleVsteger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable and tested to me

@s3cur3 s3cur3 merged commit 9ad50c3 into master Sep 5, 2024
21 checks passed
@s3cur3 s3cur3 deleted the ty/ensure-numeric-coords branch September 5, 2024 15:01
s3cur3 added a commit that referenced this pull request Sep 23, 2024
This fixes a sort-of-regression introduced in #218 (released as v4.0.0) where string values that contained only integers would previously have been passed on by the JSON parser (leading to values like `%Geo.Point{coordinates: {"12", "24"}}`) but now raise an error. Since we can unambiguously parse such values into valid integers, we should just do so.

Resolves #220
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

GeoJSON coordinates are not check nor converted to a numeric value
2 participants