ModuleCache hostname may contain symbols that are not allowed in filenames - for example, in Android device_id is used as a hostname and in some cases can have colons ("10.0.0.1:5555").
Replacing forbidden symbols with underscores in order to make hostname filesystem-friendly.
Details
Diff Detail
Event Timeline
According to https://msdn.microsoft.com/en-gb/library/windows/desktop/aa365247%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396, characters with codes 1..31 (basically < ' '), are illegal as well. We might as well convert those, just in case.
I've been sitting on a unit test for the module cache locally for a while now... I guess it's time to put that in, and then we can add a test for this as well.
At some point we should probably make a host layer call like:
const char *const char *Host::GetIllegalFilenameCharacters();" so that each host can determine the correct thing for the current host. Then FileSpec can be updated to use this function handle this with a method like "void FileSpec::NormalizePathForHost()". This will probably need to be done elsewhere.
Agree - done.
I've been sitting on a unit test for the module cache locally for a while now... I guess it's time to put that in, and then we can add a test for this as well.
Sounds good.
I like this idea of generalizing illegal symbols handling on per-platform basis - since Pavel mentioned that 1..31 range of symbols is forbidden in Windows filenames we may have a method like bool Host::IsIllegalFilenameCharacter(char) to tell whether symbol is illegal on this platform.
I like the idea of having a centralized place defining "invalid characters". However, I am not sure if that needs to be (at least in this case) system-dependent. Since presumably the code will need to work on all platforms anyway, having the escaping done in a divergent manner will just complicate testing. I don't see a reason to not define the illegal characters as a union of illegal characters across all platforms (which basically means, using the windows set).