XH_secondLanguages checks for . and ..

A place to report and discuss bugs - please mention CMSimple-version, server, platform and browser version
Post Reply
cmb
Posts: 13342
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

XH_secondLanguages checks for . and ..

Post by cmb » Thu Jun 05, 2014 10:26 pm

Hello Community,

Michel has found a bug in CMSimple_XH 1.6.2, where the function XH_secondLanguages (in cmsimple/functions.php) checks whether . and .. are second language folders. Of course, they are not, so the check is superfluous. Furthermore this check might trigger warnings due to open_basedir restrictions, because it will try to access a folder above the webroot.

I suggest that we fix it by simply ignoring all hidden files/folders (folders starting with a dot can't be language folders anyway):

Code: Select all

function XH_secondLanguages()
{
    global $pth;
    static $langs;

    if (!isset($langs)) {
        $langs = array();
        if ($dir = opendir($pth['folder']['base'])) {
            while (($entry = readdir($dir)) !== false) {
                if ($entry[0] != '.' && XH_isLanguageFolder($entry)) { // changed
                    $langs[] = $entry;
                }
            }
            closedir($dir);
        }
        sort($langs);
    }
    return $langs;
} 
Christoph
Christoph M. Becker – Plugins for CMSimple_XH

cmb
Posts: 13342
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: XH_secondLanguages checks for . and ..

Post by cmb » Tue Aug 12, 2014 12:03 pm

Done (r1331).
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply