Skip to content

[Fixes 13919] Fix UTF-8 handling for GeoJSON uploads with non-ASCII properties#13916

Merged
mattiagiupponi merged 1 commit intoGeoNode:masterfrom
F0rtiter:master
Feb 6, 2026
Merged

[Fixes 13919] Fix UTF-8 handling for GeoJSON uploads with non-ASCII properties#13916
mattiagiupponi merged 1 commit intoGeoNode:masterfrom
F0rtiter:master

Conversation

@F0rtiter
Copy link
Contributor

Ensure GeoJSON files containing non-ASCII (e.g. Chinese) attribute values
are correctly detected and validated by explicitly decoding input as UTF-8
in GeoJsonFileHandler.

This prevents false negatives in handler detection and avoids incorrectly
reporting valid GeoJSON files as invalid due to implicit or system-dependent
encoding assumptions.

Ensure GeoJSON files containing non-ASCII (e.g. Chinese) attribute values
are correctly detected and validated by explicitly decoding input as UTF-8
in GeoJsonFileHandler.

This prevents false negatives in handler detection and avoids incorrectly
reporting valid GeoJSON files as invalid due to implicit or system-dependent
encoding assumptions.
@cla-bot
Copy link

cla-bot bot commented Jan 30, 2026

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @F0rtiter on file. In order for us to review and merge your code, please contact the project maintainers to get yourself added.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @F0rtiter, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical encoding issue that previously caused GeoJSON files with non-ASCII characters in their properties to be misidentified or fail validation. By explicitly enforcing UTF-8 decoding during file reading and content processing, the system can now accurately handle and validate such GeoJSON data, ensuring seamless integration and preventing false negatives for valid files.

Highlights

  • UTF-8 Encoding for File Reading: Modified open() calls in both the can_handle and is_valid functions to explicitly specify encoding="utf-8" when reading GeoJSON files from disk. This ensures consistent character interpretation.
  • Byte Content Decoding: Added a new logic block within the can_handle function to explicitly decode file content to UTF-8 if it is read as bytes, before passing it to json.loads. This handles cases where the input stream provides byte data.
  • Improved GeoJSON Validation: These changes collectively prevent GeoJSON files containing non-ASCII characters in their properties from being incorrectly flagged as invalid, thereby enhancing the reliability and robustness of GeoJSON uploads.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly addresses UTF-8 handling for GeoJSON file uploads by explicitly specifying encoding="utf-8" when reading files. This change aligns with the GeoJSON specification (RFC 7946), which mandates UTF-8 encoding, and improves the robustness of file processing by preventing errors with non-ASCII characters. The modifications in can_handle and is_valid methods are consistent and well-implemented, ensuring that GeoJSON files are correctly detected and validated regardless of system default encodings. The changes are a solid improvement to the GeoJSON handler.

@mattiagiupponi
Copy link
Contributor

Hi @F0rtiter thanks for the contribution, as soon as the Test suite pass i'll test the PR.
If possible, can you also open an issue explaining the use case? is more to keep track and a connection between ISSUE the PR assosiated, so when we prepare the release notes we can link the issue to them.

Thanks!

@F0rtiter
Copy link
Contributor Author

I've opened an issue describing the use case: #13919

@F0rtiter F0rtiter changed the title Fix UTF-8 handling for GeoJSON uploads with non-ASCII properties [Fixes 13919] Fix UTF-8 handling for GeoJSON uploads with non-ASCII properties Jan 31, 2026
@mattiagiupponi mattiagiupponi merged commit d93a30d into GeoNode:master Feb 6, 2026
17 of 18 checks passed
github-actions bot pushed a commit that referenced this pull request Feb 6, 2026
)

Ensure GeoJSON files containing non-ASCII (e.g. Chinese) attribute values
are correctly detected and validated by explicitly decoding input as UTF-8
in GeoJsonFileHandler.

This prevents false negatives in handler detection and avoids incorrectly
reporting valid GeoJSON files as invalid due to implicit or system-dependent
encoding assumptions.

(cherry picked from commit d93a30d)
mattiagiupponi pushed a commit that referenced this pull request Feb 6, 2026
) (#13941)

Ensure GeoJSON files containing non-ASCII (e.g. Chinese) attribute values
are correctly detected and validated by explicitly decoding input as UTF-8
in GeoJsonFileHandler.

This prevents false negatives in handler detection and avoids incorrectly
reporting valid GeoJSON files as invalid due to implicit or system-dependent
encoding assumptions.

(cherry picked from commit d93a30d)

Co-authored-by: F0rtiter <40894236+F0rtiter@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GeoJSON uploads with non-ASCII (UTF-8) properties may fail validation

2 participants