e107 icon indicating copy to clipboard operation
e107 copied to clipboard

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

Open Jimmi08 opened this issue 1 year ago • 9 comments

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

Jimmi08 avatar Dec 08 '23 17:12 Jimmi08

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.

Moc avatar Dec 21 '23 15:12 Moc

@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.

Jimmi08 avatar Dec 21 '23 15:12 Jimmi08

@CaMer0n Thoughts?

Moc avatar Dec 21 '23 15:12 Moc

@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

Jimmi08 avatar Feb 14 '24 12:02 Jimmi08

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?

Moc avatar Feb 14 '24 13:02 Moc

Next issue:

  • with ?elan=xy backslash should be mandatory otherwise e_url is not working correctly This is working example (simple page, no parameters)
            $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?

Jimmi08 avatar Apr 15 '24 13:04 Jimmi08

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?

rica-carv avatar May 04 '24 12:05 rica-carv

@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.

Jimmi08 avatar May 04 '24 12:05 Jimmi08

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....

rica-carv avatar May 04 '24 20:05 rica-carv