SCEE icon indicating copy to clipboard operation
SCEE copied to clipboard

Ignore leading and trailing whitespace in raw tag editor

Open mnalis opened this issue 4 months ago • 5 comments

as they are hard to visually spot, and we trim() them later anyway.

It will still detect whitespace in the middle of the key as a problem (as it should)

Fixes https://github.com/Helium314/SCEE/issues/822

mnalis avatar Jul 08 '25 22:07 mnalis

debug .apk at https://github.com/mnalis/StreetComplete/actions/runs/16155435454, if people would like to test if it works correctly. @matkoniecz could you confirm it fixes the issue?

Specifically, in Raw tag editor it:

  • should allow entering leading and trailing whitespace in key,
  • ... but it should remove those whitespaces before upload
  • however whitespace in the middle of the key should not be allowed (i.e. checkmark button should not apper)
  • all other invalid chars like #, =, etc should continue to not be allowed anywhere (begging, middle, or the end)

mnalis avatar Jul 08 '25 22:07 mnalis

I think it's a bit more readable to trim the keys before checking against the regex, i.e. problematicKeyCharacters.containsMatchIn(it.trim()) instead of problematicKeyCharacters.containsMatchIn(it). Do you agree, or do you prefer your changed regex?

Helium314 avatar Jul 25 '25 08:07 Helium314

Do you agree, or do you prefer your changed regex?

I'm not particularly attached to the regex, so feel free to use whatever works better !

(I only used regex because it did not require deeper understanding of codebase nor of Kotlin... When all you have is a hammer, everything tends to look like a nail :smiley: )

mnalis avatar Aug 19 '25 03:08 mnalis

Alright! I'll try both variants once I find some time, or latest when doing the next upstream merge (may take some time).

Helium314 avatar Aug 20 '25 03:08 Helium314

Works, so I adjusted the PR. As usual lately, merge will have to wait.

Helium314 avatar Aug 20 '25 17:08 Helium314