openstreetmap / openstreetmap-website

The Rails application that powers OpenStreetMap
https://www.openstreetmap.org/
GNU General Public License v2.0
2.15k stars 908 forks source link

Spaces and underscores in links #3881

Open maro-21 opened 1 year ago

maro-21 commented 1 year ago

The OSM website treats underscores and spaces in links the same way, but in OSM tags it matters.

https://osm.org/way/514021415/history

Click on the "place of worship" in the version 3 and "place_of_worship" in the version 4. You will see that the link directs you to the same Wiki page, even though tags amenity=place of worship and amenity=place_of_worship are technically different. Visually we can see spaces and underscores, but due to the fact that there is a blue link to the Wiki page, it's hard to see that the tag is invalid.

tomhughes commented 1 year ago

Well it doesn't really matter because the wiki apparently treats them as the same anyway... It must be deliberate so I assume whoever wrote the code had a good reason and better knowledge of how mediawiki handle these things than I do.

tomhughes commented 1 year ago

https://github.com/openstreetmap/openstreetmap-website/blob/master/app/helpers/browse_tags_helper.rb#L44 seems to be the explanation, that the script that scrapes the wiki normalises on space.

tomhughes commented 1 year ago

Sorry, it normalises the keys to underscore, but the values have spaces as you can see in config/wiki_pages.yml so the page names we link to have spaces.

maro-21 commented 1 year ago

This script ok for links to Wikipedia and other Wikis in the tags such as wikipedia, brand:wikipedia, wikimedia_commons etc., but the tag amenity=place of worship with spaces won't be rendered on the map as a place of worship. Looking at the set of tags, everything looks ok at first glance when we see the correct link, but this is what may cause us not to find out what is wrong without opening the editor.

So for example: wikipedia=en:Open Street Map and wikipedia=en:Open_Street_Map is technically the same, but amenity=place_of_worship and amenity=place of worship is not.

mmd-osm commented 1 year ago

Relevant code in the wiki scraping script: https://github.com/openstreetmap/openstreetmap-website/blob/master/script/misc/update-wiki-pages#L93-L97