e107inc / e107

e107 Bootstrap CMS (Content Management System) v2 with PHP, MySQL, HTML5, jQuery and Twitter Bootstrap. Issue Discussion Room: https://gitter.im/e107inc/e107
https://e107.org
GNU General Public License v3.0
318 stars 212 forks source link

[Bug]: 2 ways for creating url pages - e_SELF versus e_url addon #5142

Open Jimmi08 opened 6 months ago

Jimmi08 commented 6 months ago

What e107 version are you using?

v2.3.3

Bug description

I noticed this with chatbox menu - just because it changed my layout so I knew that URL was changed.

chatbox menu is using for form post URL e_SELF. But it is different from the actual URL and the difference is in the backslash.

In e107_class2.php is this code:

        if(substr($requestSelf,-4) !== '.php' && substr($requestSelf,-1) !== '/')
        {
            $requestSelf .= '/'; // Always include a trailing slash on SEF Urls so that e_REQUEST_SELF."?".e_QUERY doesn't break.
        }

Always include a trailing slash on SEF Urls so that e_REQUEST_SELF."?".e_QUERY doesn't this is correct and it should work that way. Only that you should test .html too - it is sef-url way for news.

But e_url addon for forum has:

        $config['index'] = array(
            'regex'         => '^forum\/?$',                         
            'sef'           => 'forum',                              
            'redirect'      => '{e_PLUGIN}forum/forum.php',          
            'legacy'        => '{e_PLUGIN}forum/forum.php',
        );

no backslash - so URL in navigation is site/forum and URL in chatbox menu is site/forum/

I don't think it should work this way.

How to reproduce

Install the forum plugin and add chatbox menu on forum page (sidebar layout)

Expected behavior

Stay on the same URL aftes posting message in chatbox

What browser(s) are you seeing the problem on?

Chrome / Brave

PHP Version

7,4

Moc commented 6 months ago

I didn't look into this yet, but just a general comment. The chatbox code is quite outdated, so I don't recommend taking it as an example of the code that you should use. The forum is a better example.

Jimmi08 commented 6 months ago

@Moc exactly so I looked at forum and there is the same issue. This is written and used in e107_class.php (and correct! )

// Always include a trailing slash on SEF Urls so that e_REQUEST_SELF."?".e_QUERY doesn't break.

but e_url addon is not using this rule in forum plugin and others.

Moc commented 6 months ago

@CaMer0n Thoughts?

Jimmi08 commented 4 months ago

@Moc @CaMer0n

This is important. The actual custom page is without a backslash. A URL with the backslash works too, but a canonical URL is still without a backslash.

At least tell me where to change for pages. Thanks

Moc commented 4 months ago

Ok, so we need clarity on the standard here, document it, and apply properly.

@CaMer0n can you advise on the format that should be followed in the e_url addon in relation to the ending backslash?

Jimmi08 commented 2 months ago

Next issue:

            $alias = 'submit-new-listing';
            $config['dashboard_submit'] = array(
                'alias' => $alias . "/",
                'regex' => $alias."\/",
                'sef'   => $alias . "/", 
                'redirect' => '{e_PLUGIN}property/pages/dashboard_submit.php'
            );

without backslash multilan version is not working. Yeah, probably it can be solved with better regex, but why, if elan is core stuff a only what is needed is adding backslash?

rica-carv commented 1 month ago

Sorry for digging this up, but it seems that i have some similar issue.

For instance, i have a plugin with the SEF url site\philcat, that redirs to the correct url as per e_ulr rules:

$config['index'] = array(
'regex'      => '^{alias}\/?$',         // matched against url, and if true, redirected to 'redirect' below.
'sef'       => '{alias}',           // used by e107::url(); to create a url from the db table.
'redirect'  => '{e_PLUGIN}philcat/philcat.php',         // file-path of what to load when the regex returns true.
'legacy'    => '{e_PLUGIN}philcat/philcat.php',         // file-path of what to load when the regex returns true.);

But if i use the E_SELF constant on a template to get the current url, it comes with the final backslash, ie: url site\philcat\, and if i use it in a href, the page gives an error, because the rule wont work....

What can i be doing wrong here?

Jimmi08 commented 1 month ago

@rica-carv this is one of the more important issues I have talked about before...

Use this in your plugin: 'alias' => $alias . "/",

There always should be backslash in URLs if SEF-URL is used.
Not to mention that theme layout depends on URLs and parameters in URL can change Frontpage layout.

rica-carv commented 1 month ago

Wow, this is a mess.... For instance, there's some core plugins that have its master links on the main page without the final slash (forum, downloads, contact ), and others do have the final slash (links)....

This way there's no SEF that can resist....