Screenshot filename has invalid characters#253
Conversation
The screenshot filename "firefox_2016-07-12T15:19:21+00:00.578f8b3deeff62.22313382.png" contains invalid characters on Windows. This PR changes it to "firefox_2016-07-20_16.31.25_578f8b3deeff62.22313382.png"
Which exactly characters? |
| // Under Cygwin, uniqid with more_entropy must be set to true. | ||
| // No effect in other environments. | ||
| $filename = $filename ?: sprintf('%s_%s_%s.%s', $this->getMinkParameter('browser_name'), date('c'), uniqid('', true), 'png'); | ||
| $filename = $filename ?: sprintf('%s_%s_%s.%s', $this->getMinkParameter('browser_name'), date('Y-m-d_H.i.s'), uniqid('', true), 'png'); |
There was a problem hiding this comment.
Maybe it is better to:
- use
date('c')as before - afterwards apply regular expression, that would replace all non filename safe characters
?
There was a problem hiding this comment.
@aik099 I'm not sure why that would be better. It would increase the amount of processing needed when we have full control over the filename anyway.
There was a problem hiding this comment.
If you can guarantee, that other components in filename (e.g. browser_name and uniqid) won't ever contain forbidden symbols, then of course keep PR code as-as.
|
@aik099 The colons are reserved characters in Windows file systems https://msdn.microsoft.com/en-gb/library/windows/desktop/aa365247%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396. Altough the + is valid, I think it's best to stick to normal filename characters. |
The screenshot filename "firefox_2016-07-12T15:19:21+00:00.578f8b3deeff62.22313382.png" contains invalid characters on Windows. This PR changes it to "firefox_2016-07-20_16.31.25_578f8b3deeff62.22313382.png"