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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Rob C’s picture

Subscribe, 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

Blooniverse’s picture

Issue tags: -twitter-ssl

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

xurizaemon’s picture

Title: No twittering of source SSL-URLs, please! » Post links to http rather than https URLs
Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Active » Closed (won't fix)

If 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 :)

ErikWegner’s picture

Version: 7.x-3.x-dev » 7.x-5.x-dev
Status: Closed (won't fix) » Needs review
FileSize
1.37 KB

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

xurizaemon’s picture

Issue summary: View changes
Status: Needs review » Needs work

Eh, 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?

ErikWegner’s picture

FileSize
2.55 KB

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

xurizaemon’s picture

Thanks 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

URL protocol

By default ("no change"), the Twitter module will inherit the protocol used at time of node submission for replacements !url, !url-alias and !tinyurl.

Use "Force https" to ensure those replacements use the https protocol.

Use "Force http only" to modify those replacements to use http protocol.

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

ErikWegner’s picture

FileSize
3.18 KB
  1. According to #793458-7: Post links to http rather than https URLs, the description is changed.
  2. The url handling is done for all three tokens.
ErikWegner’s picture

FileSize
8.24 KB

This is a much improved version to handle the url published to twitter.

It now supports:

  1. Switch to http or https
  2. Change the hostname
  3. Add a port number
  4. Add additional get parameters, e.g. to support Piwik or Google Analytics campaign
ErikWegner’s picture

FileSize
8.44 KB

This is a much improved version to handle the url published to twitter.

It now supports:

  1. Switch to http or https protocol
  2. Change the hostname
  3. Add a port number
  4. Add additional get parameters, e.g. to support Piwik or Google Analytics campaign
  5. Removes the port number from the final url, if it is not required by the protocol.

The settings affect the !url and !url-alias token replacements.

DamienMcKenna’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 10: twitter-post-url-handling-793458-10.patch, failed testing.

DamienMcKenna’s picture

DamienMcKenna’s picture

One request: rename the variables to say "https" instead of "ssl", because strictly speaking browsers are dumping SSL in favor of TLS.

DamienMcKenna’s picture

Leeteq’s picture

Leeteq’s picture

Ok, 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.)

Leeteq’s picture

Priority: Normal » Major
ErikWegner’s picture

FileSize
8.32 KB

Patch updated to new release 7.x-5.x.

DamienMcKenna’s picture

Status: Needs work » Needs review
IsaMic’s picture

Hi,

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.