From 077d9a510510744cea15a64fe4566e85800aaf44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=E2=84=93e=20Hensel?= Date: Wed, 24 May 2023 09:21:41 +1200 Subject: [PATCH] fix tag values with whitespace causing css bugs (#9637) --- CHANGELOG.md | 3 ++- modules/svg/tag_classes.js | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce5ced9ce..2ba34802f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,7 +49,7 @@ _Breaking developer changes, which may affect downstream projects or sites that * Fix corruption of tag values of fields with referenced strings, but restricted `options`, when an unavailable option is entered manually into the field. * Properly handle case sensitive tag values in taginfo suggestions in raw tag editor ([#9640]) * Fix dysfunctional autocomplete of wikidata fields for some languages with country-codes ([#9638]) - +* Prevent certain tag values from corrupting css classes when they contain whitespaces ([#9637], thanks [@k-yle]) #### :earth_asia: Localization * Send `Accept-Language` header on Nominatim API calls ([#9501], thanks [@k-yle]) * Add Address and Phone Format for India ([#9482], thanks [@biswajit-k]) @@ -70,6 +70,7 @@ _Breaking developer changes, which may affect downstream projects or sites that [#9493]: https://github.com/openstreetmap/iD/pull/9493 [#9520]: https://github.com/openstreetmap/iD/pull/9520 [#9501]: https://github.com/openstreetmap/iD/pull/9501 +[#9637]: https://github.com/openstreetmap/iD/pull/9637 [#9638]: https://github.com/openstreetmap/iD/pull/9638 [#9640]: https://github.com/openstreetmap/iD/issues/9640 [@biswajit-k]: https://github.com/biswajit-k diff --git a/modules/svg/tag_classes.js b/modules/svg/tag_classes.js index e358e9903..cf535c34f 100644 --- a/modules/svg/tag_classes.js +++ b/modules/svg/tag_classes.js @@ -159,7 +159,12 @@ export function svgTagClasses() { classes.push('tag-wikidata'); } - return classes.join(' ').trim(); + // ensure that classes for tags keys/values with special characters like spaces + // are not added to the DOM, because it can cause bizarre issues (#9448) + return classes + .filter(klass => /^[-_a-z0-9]+$/.test(klass)) + .join(' ') + .trim(); };