streetcomplete / StreetComplete

Easy to use OpenStreetMap editor for Android
https://streetcomplete.app
GNU General Public License v3.0
3.85k stars 352 forks source link

Invalid characters in note comment prevent uploading #3262

Closed Drahflow closed 3 years ago

Drahflow commented 3 years ago

When trying to upload my answers, I currently see "Error while uploading answers", due to (note the zero byte in the note comment):

09-05 22:23:46.808  2712  2732 E Upload  : Unable to upload
09-05 22:23:46.808  2712  2732 E Upload  : de.westnordost.osmapi.common.errors.OsmBadUserInputException: Bad Request (400) - NoteComment : body: contains invalid characters ("Unable to answer \"Is there a cycleway here? What type?\" for https://osm.org/way/529421171 via StreetComplete 33.2:\n\nCycleway mapped\u0000 separately")
09-05 22:23:46.808  2712  2732 E Upload  :      at de.westnordost.osmapi.OsmApiErrorFactory.createError(OsmApiErrorFactory.java:40)
09-05 22:23:46.808  2712  2732 E Upload  :      at de.westnordost.osmapi.OsmConnection.handleResponseCode(OsmConnection.java:349)
09-05 22:23:46.808  2712  2732 E Upload  :      at de.westnordost.osmapi.OsmConnection.makeRequest(OsmConnection.java:195)
09-05 22:23:46.808  2712  2732 E Upload  :      at de.westnordost.osmapi.notes.NotesApi.create(NotesApi.java:63)
09-05 22:23:46.808  2712  2732 E Upload  :      at de.westnordost.streetcomplete.data.osmnotes.NotesApiImpl.create(NotesApiImpl.kt:28)
...

How to Reproduce

Somehow convince the note input field to accept a zero byte (honestly no idea how my android keyboard got the idea to do that).

Versions affected

StreetComplete: v33.2 Android: 9, but this seems irrelevant.

westnordost commented 3 years ago

It's not the input field that doesn't accept that but the OSM API.

You can report bugs for the OSM website here: https://github.com/openstreetmap/openstreetmap-website

westnordost commented 3 years ago

Also, you should maybe report the bug to the keyboard software (if it is open source), a keyboard shouldn't add characters you didn't type. Who knows what else it does.

Drahflow commented 3 years ago

IMHO, the OSM API is entirely right in rejecting this character, it has no business being in a human readable field (and will wreak havoc in many places). But if so, Streetcomplete should not have sent this character to the API. The best moment to give user feedback would probably have been the moment the note has been submitted ("Sorry, your input contains invalid characters.")

Drahflow commented 3 years ago

In case you decide to implement input filtering, this file seems relevant: https://github.com/openstreetmap/openstreetmap-website/blob/70d7d8d850148f714b70a3297c02a8203214dec6/app/validators/characters_validator.rb

westnordost commented 3 years ago

IMO this is a case for reporting this bug to the keyboard software. I don't want to filter the input on potentially any input field.

Imagine you'd have a hardware keyboard that would randomly add invisible control characters - that would go right into the trash.

mnalis commented 3 years ago

Imagine you'd have a hardware keyboard that would randomly add invisible control characters - that would go right into the trash.

Depending on how poor you are and how easily is new keyboard obtainable, though :smile: Anyway, it might not be a random bug in keyboard software but actually a feature of the keyboard which user inadvertently activated...

Personally, I wouldn't bother with investigation and bug reporting if that is default manufacturer keyboard (as I dislike spending my time to help improve non-free software)

In such case I'd just install some different keyboard software from f-droid.org (which I always do anyway, as I find stock keyboards so full of unwanted features while still failing to provide essential things I want). If one does not want any bells & whistles, I find Simple Keyboard refreshingly simple. Or, if one sometimes needs option to have full desktop keyboard available on mobile (like for remote ssh sessions), Hacker's keyboard is good choice for me (although that one also allows to you to send control characters if you enable layout with ctrl key, so beware).