Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When I post from an SSL-URL e.g. https://sld-example.tld/edit/node/123, the Twitter module 'twitters' the SSL-URL of this particular node to Twitter.com -- for instance as a tiny URL! I find this very annoying, because one constantly needs to think about changing from https:// to http:// [in the browser location bar] before/while editing/creating nodes.
Comment | File | Size | Author |
---|---|---|---|
#22 | twitter-post-url-handling-793458-22.patch | 8.83 KB | IsaMic |
| |||
#20 | twitter-post-url-handling-793458-20.patch | 8.32 KB | ErikWegner |
Comments
Comment #1
Rob C CreditAttribution: Rob C commentedSubscribe, didn't try the current dev, but has this feature a future? else:
@the_phi you can easily hardcode it, but yes, a better option would be to have this as an option on the config page.
Just bumped on to this with a page the editors need to post to twitter with a tinyurl address, but they all want to work on an SSL enabled host. (To be honest, for security this is key if you ask me.)
edit:
a quick fix to force it to http:// would be something like:
open up modules/twitter/twitter_post/twitter_post.module
search for the function:
function twitter_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
then search for this line:
$replacements['!tinyurl'] = twitter_shorten_url(url('node/'. $node->nid, array('absolute' => TRUE)));
replace it with something like:
$replacements['!tinyurl'] = twitter_shorten_url('http://'.$_SERVER['SERVER_NAME'].url('node/'. $node->nid, array('absolute' => FALSE)));
sorry, no patch
Comment #2
Blooniverse CreditAttribution: Blooniverse commentedCorrect, thank you, @AllRob! I am just trying to avoid individual patching. Should the Twitter 7.x version still have this kind of wrong behaviour, I will definitely do it the way you have proposed.
Comment #3
xurizaemonIf a patch is put forward for this, it needs to handle SSL-only sites, which wouldn't want to go posting broken http links. Probably needs to be a configurable feature which people enable. Possibly nodewords or securepages will give you some additional tools to handle outputting your preferred protocol.
No action in over a year so closing, feel free to re-open with a patch :)
Comment #4
ErikWegner CreditAttribution: ErikWegner commentedThis patch does not care about SSL-only sites. It just adds another token that can be used to always post the non-ssl url to twitter. The new token is simply named
!tinyurlnossl
.Comment #5
xurizaemonEh, sorry this issue is taking a year per reply round trip. But ...
$_SERVER['SERVER_NAME'] is dependent on the server supplying that variable (There is no guarantee that every web server will provide any of these; servers may omit some, or provide others not listed here.) and there's even no guarantee there will be a server when this is called (cron via Drush).
I suspect it'd be better to manually replace the protocol in the output of url() than to use that?
Comment #6
ErikWegner CreditAttribution: ErikWegner commentedNew patch added: Instead of adding a new token, a new setting is available. This setting controls modifications of the submitted url.
This gives you the option to a) do nothing, b) always change the protocol to http, c) always change the protocol to https.
Comment #7
xurizaemonThanks Erik. I have two suggested improvements to this -
Since #1816308: Consider removing twitter_shorten_url() ? we use !url-alias per default instead of !tinyurl (since Twitter already shorten the URL via t.co, most sites will just use the actual URL unless they push via TinyURL for stats), so I'd suggest applying this to !tinyurl, !url and !url-alias rather than only !tinyurl. This pretty much just involves moving your logic up a few lines and making it apply to all three URLs.
I would then re-word the instructions on the twitter_post_ssltype setting to account for this, eg
(I'd avoid discussion of self-signed certificates, since peoples reasons for choosing to use or not use https are not specific to that use case.)
Comment #8
ErikWegner CreditAttribution: ErikWegner commentedComment #9
ErikWegner CreditAttribution: ErikWegner commentedThis is a much improved version to handle the url published to twitter.
It now supports:
Comment #10
ErikWegner CreditAttribution: ErikWegner commentedThis is a much improved version to handle the url published to twitter.
It now supports:
The settings affect the
!url
and!url-alias
token replacements.Comment #11
DamienMcKennaComment #14
DamienMcKennaClosed a duplicate: #2275985: Base url not configurable
Comment #15
DamienMcKennaOne request: rename the variables to say "https" instead of "ssl", because strictly speaking browsers are dumping SSL in favor of TLS.
Comment #16
DamienMcKennaClosed a duplicate: #2556931: Internal path as argument
Comment #17
Leeteq CreditAttribution: Leeteq commentedComment #18
Leeteq CreditAttribution: Leeteq commentedOk, so for the record as per the related/duplicate issue;
- this is not only about httpS/http, but actually about the whole base path, as the HTTPS site may be on a completely different domain, when someone has a security certificate already working and dont need/want to buy extra certs for its add-on domains.
Edit: AND; fwiw, for the flexibility and understanding; this issue does not strictly speaking need to be limited to SSL / non-SSL either, as there may be sites that provide logins from other ("root") domains via subfolders for other reasons, and not necessarily using SSL for any of those. (In fact, with more and more Two-Factor-Authentication - 2FA/U2F - solutions maturing (TFA and Yubikey modules, for example), we will probably see more of that, where SSL is irrelevant if it was only to protect the login/password.)
(Hence; the current issue title is not identifying this problem precisely.)
Comment #19
Leeteq CreditAttribution: Leeteq commentedComment #20
ErikWegner CreditAttribution: ErikWegner as a volunteer commentedPatch updated to new release 7.x-5.x.
Comment #21
DamienMcKennaComment #22
IsaMic CreditAttribution: IsaMic commentedHi,
Unfortunately the patch applies only to !url and !url-alias and do not plan to !tinyurl.
As I needed to !tinyurl so I improved the patch.