https or not https

Discussion corner for Developers of Serendipity.
Post Reply
Boris

https or not https

Post by Boris »

I just discovered, that "my" sitemap-plugin does use https-Links all over the file if I edit entries via HTTPS.
I have turned on Hostname-Autosensing, because otherwise the CSS-file is not found and the admin-panel looks quite ugly.

Is there any way to circumvent this behaviour? I added a quick hack to my local copy, but it would be nice to have a cleaner solution, so that I don't have to fork my only plugin locally :-)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: https or not https

Post by garvinhicking »

Hi!

Actually no - when you access your blog with a HTTPS URL, serendipity needs to change all $serendipity['baseURL'] references to HTTPS, thus making all variables point to https.

In your case I believe the really best way is to fetch the 'BaseURL' directive frmo the serendipity_config database table instead of using $serendipity['baseURL'] immediately.

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Boris

Post by Boris »

Ok, I'll do it that way then. Thanks.


But I think there's one bug within the configuration, when I do these steps:

* Admin-Panel (opened with http or https) -> Path-configuration -> set url to "http://example.com/" -> save
* check in the mysql-table -> "http://example.com" -> ok
* Admin-Panel (opened with https) -> Path-configuration -> url is now https://example.com:443/ and would be saved if you don't change it.

It looks like the configuration uses $serendipity['baseURL'] too.
Boris

Post by Boris »

:( Another issue: The plugin does not use $serendipity['baseURL'] directly that much, but functions like serendipity_archiveURL or serendipity_rewriteURL.

A good solution would be to do

Code: Select all

preg_replace("#^{$serendipity['baseURL']}#", fetch_baseURL_from_db_blackbox(), $url)
wouldn't it? I don't see any drawbacks with this one.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Hm, you're right. This is pretty hard, because usually having 'baseURL' set as your current URL when autodetection is on is really the proper way to go. I don't really have any good idea about this right now.

Code: Select all

preg_replace("#^{$serendipity['baseURL']}#", fetch_baseURL_from_db_blackbox(), $url)
This would work, even though it's a bit "nasty" with those regexps. One alternative would be to use

Code: Select all

function blabla()
$old_url = $serendipity['baseURL'];
$serendipity['baseURL'] = fetch_from_db();
... do tasks...
$serendipity['baseURL'] = $old_url;
This way you wouldn't need to perform so many string replacements, because you change the global variable to what you currently "need"...?

REgards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Hm, you're right. This is pretty hard, because usually having 'baseURL' set as your current URL when autodetection is on is really the proper way to go. I don't really have any good idea about this right now.

Code: Select all

preg_replace("#^{$serendipity['baseURL']}#", fetch_baseURL_from_db_blackbox(), $url)
This would work, even though it's a bit "nasty" with those regexps. One alternative would be to use

Code: Select all

function blabla()
$old_url = $serendipity['baseURL'];
$serendipity['baseURL'] = fetch_from_db();
... do tasks...
$serendipity['baseURL'] = $old_url;
This way you wouldn't need to perform so many string replacements, because you change the global variable to what you currently "need"...?

REgards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Boris

Post by Boris »

I did it your way now.

This only leaves the issue described earlier.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Yes, but if you change $serendipity['baseURL'] before you use serendipity_archiveURL and other functions, that issue is fixed as well?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Boris

Post by Boris »

Sorry, that was the wrong link. :oops:

I did mean this issue in the configuration.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Yes, that's true, the admin will have to ensure that the right link is added there. Technically it would mean a fundamental change in the configuration routine to make it differently. It would be nice to do that somewhen in the future, but currrently it's not IMHO such a pressing issue :)

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Boris

Post by Boris »

garvinhicking wrote:It would be nice to do that somewhen in the future, but currrently it's not IMHO such a pressing issue :)
I trust you, that you're right :-)

I rarely change my config, but if I do I'll forget to change it back. I guess a cronjob would be good for me.
Post Reply