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

Sanitize uploaded layers that start with a numeric character #12749

Open
giohappy opened this issue Nov 27, 2024 · 1 comment
Open

Sanitize uploaded layers that start with a numeric character #12749

giohappy opened this issue Nov 27, 2024 · 1 comment
Assignees
Milestone

Comments

@giohappy
Copy link
Contributor

Geoserver layers starting with a numeric character will throw an error when accessed as GML through WFS. This prevents loading these layers from third-party applications that request WFS data as GML (e.g. QGIS).

The importer will prefix the name of these layers with an underscore ("_") character.

@giohappy giohappy added this to the 5.0.0 milestone Nov 27, 2024
@mattiagiupponi
Copy link
Contributor

mattiagiupponi commented Nov 27, 2024

NOTE: the fix should be put here

def fixup_name(self, name):
"""
Emulate the LAUNDER option in ogr2ogr which will normalize the string.
This is enriched with additional transformation for parentesis.
The basic normalized function can be found here
https://github.com/OSGeo/gdal/blob/0fc262675051b63f96c91ca920d27503655dfb7b/ogr/ogrsf_frmts/pgdump/ogrpgdumpdatasource.cpp#L130 # noqa
We use replace because it looks to be one of the fasted options:
https://stackoverflow.com/questions/3411771/best-way-to-replace-multiple-characters-in-a-string
"""
return (
name.lower()
.replace("-", "_")
.replace(" ", "_")
.replace("#", "_")
.replace("\\", "_")
.replace(".", "")
.replace(")", "")
.replace("(", "")
.replace(",", "")
.replace("&", "")[:62]
)

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

No branches or pull requests

2 participants