Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image resize tool returns image path with spaces, witch utf-8 characters. #616

Closed
arnisjuraga opened this issue Apr 14, 2013 · 5 comments
Closed

Comments

@arnisjuraga
Copy link
Contributor

catalog/model/image.php "return $this->config->get('config_url') . 'image/' . $new_image;" and "return $this->config->get('config_ssl') . 'image/' . $new_image;" lines, returns image path, not formatted for HTML. If image path contains space, it will not be formatted.

The same - with UTF-8 characters in path.

Page then is not HTML validated.

@opencart
Copy link
Collaborator

don;t use spaces!

@arnisjuraga
Copy link
Contributor Author

This is completely un-contructive answer! :(
The same would be - "don;t use special characters", an then - remove 'escape' method from sql queries.

This is not so hard to implement - into model/tool/image, add line (v.1.5.5.1) 49:

$new_image = str_replace(' ', '%20', $new_image);

And this already helps a lot! Can I commit this?

@ghost
Copy link

ghost commented Jun 1, 2013

I'm not sure why you wouldn't just rawurlencode() it instead.

@arnisjuraga
Copy link
Contributor Author

You cannot use it at the end, because it has "/" characters in full path.
But - better would be to encode in the beginning:

$encoded_filename=str_replace('%2F','/', rawurlencode(utf8_substr($filename, 0, utf8_strrpos($filename, '.'))));
$new_image = 'cache/' . $encoded_filename . '-' . $width . 'x' . $height . $type .'.' . $extension;
  1. it replaces all spec chars,
  2. then - decodes "%2F" character back to "/"

@arnisjuraga
Copy link
Contributor Author

Opencart CE edition accepted this as issue and made a fix:

opencart-ce/opencart-ce@b1efd52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant