RESOLVED: [ 2020.20625 - x64 - Win10 ] tdu.legalName() bug?

Hi, I’m not sure if this is a bug or expected results, but tdu.legalName() does not catch forward slashes. The only reason I expect that it should is because a td node’s name does not allow for slashes of any kind, and backwards slashes are indeed caught by the function.

I noticed that too. This is an old function and probably should have been named legalPath. Will pass this on

1 Like

Ohh I see - well it’s a wildly useful function ! use it for constraining user input for things that need names very frequently. At present I’m running this function on the string, then just doing a find replace for forward slashes after as a patch for my own use case.

That’s my solution too. Now that you have brought it up in the forums I’ll see if we can get it changed

Returning to this, not sure if it got fixed in the latest release, but still the same behaviour in 2020.25380 (legaxy product I support). It should def catch “/” and maybe implement legalPath as a replacement.

using

re.sub("[^0-9a-zA-Z]+", "_", a_string) now instead.

2022.20k will include validName and validPath.

For backwards compatibility reasons, legalName will quietly stick around.

1 Like