enonic / xp

Enonic XP
https://enonic.com
GNU General Public License v3.0
201 stars 34 forks source link

lib-common.sanitize trims starting and ending underscore and converts other underscores to hyphen #7437

Closed ComLock closed 4 years ago

ComLock commented 5 years ago

The documentation: https://repo.enonic.com/public/com/enonic/xp/docs/7.0.2/docs-7.0.2-libdoc.zip!/module-common.html#.sanitize

Says: replace punctuation symbols and blank spaces with the hyphen character ('-')

So does that mean that underscore is a punctuation symbol?

The problem is that the documentation also states: Some usage examples are: XP node name

I mostly use sanitize on the value of the _name property when doing node.create.

Last week @sigdestad (and I) found that it's allowed to make property names starting with underscore (this was told to @GlennRicaud). Similarly it's allowed to set a value for the _name property which starts with an underscore.

Thus lib-common.sanitize is more strict than what the node layer allows for...

GlennRicaud commented 4 years ago

As the description says, this sanitize for node names and not property names. We could have a sanitization library with a method for each case of sanitization