Re: spaces in hdf keys?

Nikolai Kondrashov <[email protected]> Wed, 13 Jan 2010 02:02:37 +0300
Newsgroups gmane.text.clearsilver.general
Message-ID <[email protected]>
Brandon Long wrote:
> As David points out, there is no validation on HDF keys when calling the
> C API to add them to a dataset.  So, the only character that's
> meaningful in a key is the dot between levels in the hierarchy.  People
> have asked for validation before, but I haven't done it because of the
> performance hit and because it would break compatibility.
The validation could be added for debug build only, which will be useful for
most cases. Although, ClearSilver doesn't have a debug build, AFAIK.

> Having write string/hdf do proper escaping would require a change to the
> syntax to create an escape mechanism, which requires at least creating
> an escape character out of something that was a valid character before.
> Since the HDF syntax doesn't allow any punctuation besides dot, that
> could probably be arranged if it was useful.
Last time I checked across all the places which are dealing with the HDF
names, there were no characters to spare. I think it's HDF file reader,
which limits HDF names to [0-9a-zA-Z_.]. Yeah it says it right there in the
_hdf_read_string:

     /* Valid hdf name is [0-9a-zA-Z_.]+ */
     name = s;
     while (*s && (isalnum(*s) || *s == '_' || *s == '.')) s++;

So, personally, I'm using '_' character to escape the names explicitly, when
needed.

However, a character outside this set could be used, but it would make the
datasets unreadable by any old code.

Sincerely,
Nick