I'm running the latest magento1.9.x

I am attempting to use a webservice call to create a downloadable link to a url similar to http://dev-nffiles.somesite.org/folder/Temp/9781554132_NurseMgr%27sBookForSaleStuff.mobi

Anytime I pass a url with percent encoding, I get a response "url_not_valid".

Assume I have xdebug and phpstorm, and I have a pretty good understanding of the zend framework, but i'm not going to step through magento core code for an hour. I feel like magento should support unicode percent encoding.

Can anyone recommend how I can get this to work? Its honestly out of the question to get the department creating the links to not do things like use apostrophes or spaces in the filenames.

1 Answer 1


Nevermind. I found this stupid nugget of code in the validator

public function validateUrl(&$var)

        if (is_string($var) && strlen($var) > 0) {
            $urlregex = "/^(https?|ftp)\:\/\/([a-z0-9+\!\*\(\)\,\;\?\&\=\$\_\.\-]+(\:[a-z0-9+\!\*\(\)\,\;\?\&\=\$\_\.\-]+)?@)?[a-z0-9\+\$\_\-]+(\.[a-z0-9+\$\_\-]+)*(\:[0-9]{2,5})?(\/([a-z0-9+\$\_\-]\.?)+)*\/?(\?[a-z\+\&\$\_\.\-][a-z0-9\;\:\@\/\&\%\=\+\$\_\.\-]*)?(#[a-z\_\.\-][a-z0-9\+\$\_\.\-]*)?$/i";
            if (!preg_match($urlregex, $var)) {
                throw new Exception('url_not_valid');
        } else {
            $var = '';
  • How did you solved this? May you can add some information and mark you answer as "best one" :)
    – sv3n
    Mar 21, 2018 at 20:42
  • You have to pass in urls that work with this regex. I'm trying to figure out a .net solution but i'm having trouble encoding the thing. I do know that magento doesn't support percent encoding.
    – CarComp
    Mar 21, 2018 at 20:57
  • 1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.