Jump to content

Recommended Posts

Posted

Someone messaged me asking to post this:

Hi ive found a bug in the api system but i can't post on the forum. If i share the info with you could you post it or get it to the correct location? 

file: system/Dispatcher/Api.php

function: _setPath()

protected function _setPath()
{
    /* Decode URL */
    if (\IPS\Settings::i()->use_friendly_urls && \IPS\Settings::i()->htaccess_mod_rewrite && mb_substr(\IPS\Request::i()->url()->data[\IPS\Http\Url::COMPONENT_PATH], -14) !== '/api/index.php') {
        /* We are using Mod Rewrite URLs, so look in the path */
        $this->path = mb_substr(\IPS\Request::i()->url()->data[\IPS\Http\Url::COMPONENT_PATH], mb_strpos(\IPS\Request::i()->url()->data[\IPS\Http\Url::COMPONENT_PATH], '/api/') + 5);

        /* nginx won't convert the 'fake' query string to $_GET params, so do this now */
        if (!empty(\IPS\Request::i()->url()->data[\IPS\Http\Url::COMPONENT_QUERY])) {
            parse_str(\IPS\Request::i()->url()->data[\IPS\Http\Url::COMPONENT_QUERY], $params);
            foreach ($params as $k => $v) {
                if (!isset(\IPS\Request::i()->$k)) {
                    \IPS\Request::i()->$k = $v;
                }
            }
        }
    } else {
       
        $this->path = mb_substr(\IPS\Request::i()->url()->data[\IPS\Http\Url::COMPONENT_PATH], mb_strpos(\IPS\Request::i()->url()->data[\IPS\Http\Url::COMPONENT_PATH], '/api/') + 5);


        /* However, if we passed any actual query string arguments, we need to strip those */
        if (mb_strpos($this->path, '?') !== false) {
            $this->path = mb_substr($this->path, 0, mb_strpos($this->path, '?'));
        }

    }
}
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...