From 9779f320a8368e52a1730630d48cb28d8b0140cd Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Tue, 16 May 2023 17:06:39 +0200 Subject: [PATCH] Properly handle case sensitive tags in taginfo suggestion in raw tag editor, fixes #9640 --- CHANGELOG.md | 2 ++ modules/osm/tags.js | 3 +++ modules/services/taginfo.js | 4 ++-- modules/ui/sections/raw_tag_editor.js | 4 +++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19a81babc..0205f2ace 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ _Breaking developer changes, which may affect downstream projects or sites that * Fix a bug where the _Add_ input element on comboboxes with a fixed set of allowed options is still hidden after an option of a previously "fully saturated" field is removed * Fix wrongly flagged "incorrect geometry type" warnings for features with lifecycle-prefixed tags ([#9483], thanks [@biswajit-k]) * 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]) #### :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]) @@ -67,6 +68,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 +[#9640]: https://github.com/openstreetmap/iD/issues/9640 [@biswajit-k]: https://github.com/biswajit-k diff --git a/modules/osm/tags.js b/modules/osm/tags.js index 2fcf98cae..af1a2d022 100644 --- a/modules/osm/tags.js +++ b/modules/osm/tags.js @@ -242,3 +242,6 @@ export var osmRailwayTrackTagValues = { export var osmFlowingWaterwayTagValues = { canal: true, ditch: true, drain: true, fish_pass: true, river: true, stream: true, tidal_channel: true }; + +// Tags which values should be considered case sensitive when offering tag suggestions +export const allowUpperCaseTagValues = /network|taxon|genus|species|brand|grape_variety|royal_cypher|listed_status|booth|rating|stars|:output|_hours|_times|_ref|manufacturer|country|target|brewery|cai_scale|traffic_sign/; diff --git a/modules/services/taginfo.js b/modules/services/taginfo.js index bd6903cb4..283772a6d 100644 --- a/modules/services/taginfo.js +++ b/modules/services/taginfo.js @@ -4,6 +4,7 @@ import { json as d3_json } from 'd3-fetch'; import { utilObjectOmit, utilQsString } from '../util'; import { localizer } from '../core/localizer'; +import { allowUpperCaseTagValues } from '../osm/tags'; import { taginfoApiUrl } from '../../config/id.js'; @@ -312,8 +313,7 @@ export default { // A few OSM keys expect values to contain uppercase values (see #3377). // This is not an exhaustive list (e.g. `name` also has uppercase values) // but these are the fields where taginfo value lookup is most useful. - var re = /network|taxon|genus|species|brand|grape_variety|royal_cypher|listed_status|booth|rating|stars|:output|_hours|_times|_ref|manufacturer|country|target|brewery|cai_scale/; - var allowUpperCase = re.test(params.key); + var allowUpperCase = allowUpperCaseTagValues.test(params.key); var f = filterValues(allowUpperCase); var result = d.data.filter(f).map(valKeyDescription); diff --git a/modules/ui/sections/raw_tag_editor.js b/modules/ui/sections/raw_tag_editor.js index 7d669ed62..f6e769af7 100644 --- a/modules/ui/sections/raw_tag_editor.js +++ b/modules/ui/sections/raw_tag_editor.js @@ -11,6 +11,7 @@ import { localizer, t } from '../../core/localizer'; import { utilArrayDifference, utilArrayIdentical } from '../../util/array'; import { utilGetSetValue, utilNoAuto, utilRebind, utilTagDiff } from '../../util'; import { uiTooltip } from '..'; +import { allowUpperCaseTagValues } from '../../osm/tags'; export function uiSectionRawTagEditor(id, context) { @@ -437,7 +438,8 @@ export function uiSectionRawTagEditor(id, context) { }, function(err, data) { if (!err) callback(sort(value, data)); }); - })); + }) + .caseSensitive(allowUpperCaseTagValues.test(utilGetSetValue(key)))); function sort(value, data) {