GitHost.io will be shut down on June 1, 2019. At that point this instance will be unreachable and all data will be irrevocably deleted. More details at https://about.gitlab.com/gitlab-hosted/#githost-is-shutting-down-on-june-1st-2019

Commit 87370f0c authored by mmn's avatar mmn

URL shortening can now be disabled for the 'maxurllength'

Also, URL shortening now consistently uses 'maxurllength'...
parent 34a66244
......@@ -794,14 +794,14 @@ external: external links in notices. One of three values: 'sometimes',
url
---
Everybody loves URL shorteners. These are some options for fine-tuning
how and when the server shortens URLs.
These are some options for fine-tuning how and when the server will
shorten URLs.
shortener: URL shortening service to use by default. Users can override
individually. 'ur1.ca' by default.
maxlength: If an URL is strictly longer than this limit, it will be
individually. 'internal' by default.
maxurllength: If an URL is strictly longer than this limit, it will be
shortened. Note that the URL shortener service may return an
URL longer than this limit. Defaults to 25. Users can
URL longer than this limit. Defaults to 100. Users can
override. If set to 0, all URLs will be shortened.
maxnoticelength: If a notice is strictly longer than this limit, all
URLs in the notice will be shortened. Users can override.
......
......@@ -61,7 +61,7 @@ class ApiStatusnetConfigAction extends ApiAction
'xmpp' => array('enabled', 'server', 'port', 'user'),
'integration' => array('source'),
'attachments' => array('uploads', 'file_quota'),
'url' => array('maxlength', 'maxnoticelength'),
'url' => array('maxurllength', 'maxnoticelength'),
);
/**
......
......@@ -136,7 +136,7 @@ class UrlsettingsAction extends SettingsAction
(!is_null($this->arg('maxurllength'))) ?
$this->arg('maxurllength') : User_urlshortener_prefs::maxUrlLength($user),
// TRANS: Field title in URL settings in profile.
_('URLs longer than this will be shortened, 0 means always shorten.'));
_('URLs longer than this will be shortened, -1 means never shorten because a URL is long.'));
$this->elementEnd('li');
$this->elementStart('li');
$this->input('maxnoticelength',
......@@ -145,7 +145,7 @@ class UrlsettingsAction extends SettingsAction
(!is_null($this->arg('maxnoticelength'))) ?
$this->arg('maxnoticelength') : User_urlshortener_prefs::maxNoticeLength($user),
// TRANS: Field title in URL settings in profile.
_('URLs in notices longer than this will always be shortened, -1 means shorten only if notice text exceeds maximum length.'));
_('URLs in notices longer than this will always be shortened, -1 means only shorten if the full post exceeds maximum length.'));
$this->elementEnd('li');
$this->elementEnd('ul');
// TRANS: Button text for saving "Other settings" in profile.
......@@ -183,7 +183,7 @@ class UrlsettingsAction extends SettingsAction
$maxurllength = $this->trimmed('maxurllength');
if (!Validate::number($maxurllength, array('min' => 0))) {
if (!Validate::number($maxurllength, array('min' => -1))) {
// TRANS: Client exception thrown when the maximum URL settings value is invalid in profile URL settings.
throw new ClientException(_('Invalid number for maximum URL length.'));
}
......
......@@ -58,7 +58,7 @@ class User_urlshortener_prefs extends Managed_DataObject
static function maxUrlLength($user)
{
$def = common_config('url', 'maxlength');
$def = common_config('url', 'maxurllength');
$prefs = self::getPrefs($user);
......
......@@ -343,7 +343,7 @@ $default =
'external' => 'sometimes'), // Options: 'sometimes', 'never', default = 'sometimes'
'url' =>
array('shortener' => 'internal',
'maxlength' => 100,
'maxurllength' => 100,
'maxnoticelength' => -1),
'http' => // HTTP client settings when contacting other sites
array('ssl_cafile' => false, // To enable SSL cert validation, point to a CA bundle (eg '/usr/lib/ssl/certs/ca-certificates.crt')
......
......@@ -2155,7 +2155,7 @@ function common_shorten_url($long_url, User $user=null, $force = false)
// $force forces shortening even if it's not strictly needed
// I doubt URL shortening is ever 'strictly' needed. - ESP
if (mb_strlen($long_url) < $maxUrlLength && !$force) {
if (($maxUrlLength == -1 || mb_strlen($long_url) < $maxUrlLength) && !$force) {
return $long_url;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment