[OSM-dev] Disallowing certain characters in tag keys

Jochen Topf jochen at remote.org
Tue Oct 19 09:11:04 BST 2010

On Sun, Oct 17, 2010 at 09:48:31AM +0200, Ulf Lamping wrote:
> Am 16.10.2010 20:44, schrieb Jochen Topf:
>> Hi!
>> I am currently fighting some issues where tags with strange characters in them
>> need to be represented in a URL for Taginfo. Lots of other websites probably
>> will have similar issues. Characters like /, ?,&, etc. have special meaning
>> in URLs so if they appear in tags I can't have those tags in URLs. Sometimes
>> escaping characters as %XX helps, sometimes not. And those problems are not
>> confined to web pages and URLs only. Special characters that need escaping
>> are often a problem.
> Yes, special characters can cause headaches. I remember this from my own  
> tag analyzing experiments and other software projects ;-)
> I agree with you that most (all?) of them are (usually unintended) bugs.  
> For example: Not long ago, it was a common tag problem that keys started  
> or ended with a space char. IIRC the xybot regularly fixes those bugs 
> now.
> However, as those characters can be used in the name values (and  
> elsewhere), you have to deal with the correct handling of special  
> characters in your software anyway, so I'm not sure if disallowing  
> special characters in the key will really help us in that regard.
> The problem with disallowing special characters is that you "close the  
> door". Software writers will then write software that depends on them  
> not being there (or not caring which is probably the common case today).  
> If we later find out that - for whatever reasons - we want to use one of  
> those chars this will become extremely difficult, as it will cause  
> trouble at many places in existing software.

Thats absolutely true. Thats why I am only proposing a very small list and
don't include characters like {} that are not used now, but might make
sense in the future.

> What we currently don't have is a guideline for mappers. I'm missing  
> (and thinking to write for some time) a: "How to write good tags". To my  
> knowledge we don't have a written guide (not rule) that we tend to used  
> lower case chars, underscores instead of spaces and all that "unwritten  
> rules". Of course, this could include: "don't use special chars like /,  
> ?, ... in keys - because this makes it hard for software writers".

I agree that we should come up with these guidelines, but thats really
a different issue.

> I tend to simply ignore keys with special chars - as we do it today ...

Which works well for lots of software (like renderers who don't care about
the things they don't understand). Unfortunately it doesn't work for editors
or something like Taginfo which needs to work with *all* legal tags.

Jochen Topf  jochen at remote.org  http://www.remote.org/jochen/  +49-721-388298

More information about the dev mailing list