pjparra / assetic-smarty

Smarty Extension for Assetic
12 stars 11 forks source link

$root calculation blows up if config_path is relative #8

Open glensc opened 7 years ago

glensc commented 7 years ago

i don't know what that $root is supposed to be, no comments in code but that place really deserves it.

but it calculates wrong

  {assetic
    assets="css/main.css,css/page.css"
    output="css"
    config_path="../config"
    build_path="style/build"
    debug=false
    filters="yui_css,less"
    asset_url=asset_url}
    <link rel="stylesheet" href="{$asset_url}">
  {/assetic}

and with given debug:

    dump('config_path='.$params['config_path']);
    $realpath = realpath($params['config_path']);
    dump('realpath='.$realpath);
    $root = mb_substr($realpath, 0, mb_strlen($realpath, $charset) - mb_strlen($params['config_path'], $charset), $charset);
    dump('root='.$root);

it results:

"config_path=../config"
"realpath=/home/glen/scm/eventum/eventum/config"
"root=/home/glen/scm/eventum/event"

that's definately wrong, whatever $root should be, it looks truncated!

pjparra commented 7 years ago

I'll have to check, but if I remember correctly, I had to get rid of it on a project where I used this plugin. If so, I'll probably commit the modification.