I am have some problems with og:image because of uploaded images with space in the filename. So could we change public static function makeSafe($file) from $regex = array('#(.){2,}#', '#[^A-Za-z0-9._- ]#', '#^.#'); to $regex = array('#(.){2,}#', '#[^A-Za-z0-9._- ]#', '#^.#','#\s#'); this would solve the problem.
Labels |
Added:
?
|
do you mean that array('#(.){2,}#', '#[^A-Za-z0-9._- ]#', '#^.#'); removes spaces? I think not. Are you shore?
I can change the img src to make it url safe, but if a make the change when I m uploading, the problem is solved in a early stage.
Ah, misunderstood you then. Ignore my comment. You are right, makeSafe
doesn't remove spaces. And I even have a workaround in my own code for that
Category | ⇒ | Libraries |
I don't really understand the issue here @yozmag. You said that you're having problems with files having spaces in the filename. But, the media manager doesn't allow the user to upload files with spaces in the filename (I just tried to do that and Joomla gave me a notice that the filename shouldn't have any spaces). So, how are you getting these files (with spaces in the filename) in the first place? Are you uploading them manually?
Anyway, I suppose, we could allow for spaces in the filename. We could either remove the spaces altogether or replace them with underscores or dashes.
I should have identifyed the place where this append, I'm on joomla 2.5.28, and this file is the same on 3.3.
On the article when uploading images "full article image" and "intro Image" the media manage lets us upload images with spaces.
I looked at make safe function and it does not remove spaces. My proposal is to remove the spaces in the makesafe function.
I just double checked with 3.4beta1
You can NOT upload an image with a space in the file name either in media
manager or when uploading images "full article image" and "intro Image"
On 30 January 2015 at 14:33, yozmag notifications@github.com wrote:
I should have identifyed the place where this append, I'm on joomla
2.5.28, and this file is the same on 3.3.
On the article when uploading images "full article image" and "intro
Image" the media manage lets us upload images with spaces.
I looked at make safe function and it does not remove spaces. My proposal
is to remove the spaces in the makesafe function.—
Reply to this email directly or view it on GitHub
#5905 (comment).
Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/
Thank you.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-01-30 15:25:15 |
The current reqex is correct.Spaces aren't a safe character in an URL, so any files which eventually end up in an URL (like media files) should never contain them.
Thus makeSafe() removes those spaces correctly.
Now I'm not sure what the issue is you have in your code. It obviously doesn't make sense to pass an already existing file location throughmakeSafe()
. It's meant to do during upload before storing a file.In case of og:image you need to take the existing URL and properly encode it instead.