summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/apiaction.php1
-rw-r--r--lib/default.php2
-rw-r--r--lib/noticeform.php14
-rw-r--r--lib/noticelist.php5
-rw-r--r--lib/stompqueuemanager.php29
-rw-r--r--lib/util.php49
6 files changed, 75 insertions, 25 deletions
diff --git a/lib/apiaction.php b/lib/apiaction.php
index 9fc1a0779..59dc47c23 100644
--- a/lib/apiaction.php
+++ b/lib/apiaction.php
@@ -318,7 +318,6 @@ class ApiAction extends Action
$twitter_group['url']=$group->permalink();
$twitter_group['nickname']=$group->nickname;
$twitter_group['fullname']=$group->fullname;
- $twitter_group['homepage_url']=$group->homepage_url;
$twitter_group['original_logo']=$group->original_logo;
$twitter_group['homepage_logo']=$group->homepage_logo;
$twitter_group['stream_logo']=$group->stream_logo;
diff --git a/lib/default.php b/lib/default.php
index 745e8d850..7f9cd7eac 100644
--- a/lib/default.php
+++ b/lib/default.php
@@ -88,6 +88,8 @@ $default =
'stomp_username' => null,
'stomp_password' => null,
'stomp_persistent' => true, // keep items across queue server restart, if persistence is enabled
+ 'stomp_transactions' => true, // use STOMP transactions to aid in detecting failures (supported by ActiveMQ, but not by all)
+ 'stomp_acks' => true, // send acknowledgements after successful processing (supported by ActiveMQ, but not by all)
'stomp_manual_failover' => true, // if multiple servers are listed, treat them as separate (enqueue on one randomly, listen on all)
'monitor' => null, // URL to monitor ping endpoint (work in progress)
'softlimit' => '90%', // total size or % of memory_limit at which to restart queue threads gracefully
diff --git a/lib/noticeform.php b/lib/noticeform.php
index a55839de0..7278c41a9 100644
--- a/lib/noticeform.php
+++ b/lib/noticeform.php
@@ -189,14 +189,10 @@ class NoticeForm extends Form
}
if (common_config('attachments', 'uploads')) {
- $this->out->element('label', array('id' => 'notice_data-attach-label',
- 'class' => 'attach-label',
- 'for' => 'notice_data-attach'),
- _('Attach'));
+ $this->out->element('label', array('for' => 'notice_data-attach'),_('Attach'));
$this->out->element('input', array('id' => 'notice_data-attach',
- 'class' => 'attach',
'type' => 'file',
- 'name' => 'attach0',
+ 'name' => 'attach',
'title' => _('Attach a file')));
$this->out->hidden('MAX_FILE_SIZE', common_config('attachments', 'file_quota'));
}
@@ -216,10 +212,8 @@ class NoticeForm extends Form
$this->out->checkbox('notice_data-geo', _('Share my location'), true);
$this->out->elementEnd('div');
$this->out->inlineScript(' var NoticeDataGeo_text = {'.
- 'ShareDisable: ' .json_encode(_('Do not share my location')).','.
- 'ErrorTimeout: ' .json_encode(_('Sorry, retrieving your geo location is taking longer than expected, please try again later')).
- '} ; var NoticeAttachment_text = {'.
- 'AttachFile: ' . json_encode(_('Attach a file')) .
+ 'ShareDisable: "'._('Do not share my location').'",'.
+ 'ErrorTimeout: "'._('Sorry, retrieving your geo location is taking longer than expected, please try again later').'"'.
'}');
}
diff --git a/lib/noticelist.php b/lib/noticelist.php
index 0d4cd4dd9..83c8de9f6 100644
--- a/lib/noticelist.php
+++ b/lib/noticelist.php
@@ -340,8 +340,9 @@ class NoticeListItem extends Widget
function showNickname()
{
- $this->out->element('span', array('class' => 'nickname fn'),
- $this->profile->nickname);
+ $this->out->raw('<span class="nickname fn">' .
+ htmlspecialchars($this->profile->nickname) .
+ '</span>');
}
/**
diff --git a/lib/stompqueuemanager.php b/lib/stompqueuemanager.php
index 9af8b2f48..5d5c7ccfb 100644
--- a/lib/stompqueuemanager.php
+++ b/lib/stompqueuemanager.php
@@ -39,7 +39,8 @@ class StompQueueManager extends QueueManager
protected $base;
protected $control;
- protected $useTransactions = true;
+ protected $useTransactions;
+ protected $useAcks;
protected $sites = array();
protected $subscriptions = array();
@@ -59,11 +60,13 @@ class StompQueueManager extends QueueManager
} else {
$this->servers = array($server);
}
- $this->username = common_config('queue', 'stomp_username');
- $this->password = common_config('queue', 'stomp_password');
- $this->base = common_config('queue', 'queue_basename');
- $this->control = common_config('queue', 'control_channel');
- $this->breakout = common_config('queue', 'breakout');
+ $this->username = common_config('queue', 'stomp_username');
+ $this->password = common_config('queue', 'stomp_password');
+ $this->base = common_config('queue', 'queue_basename');
+ $this->control = common_config('queue', 'control_channel');
+ $this->breakout = common_config('queue', 'breakout');
+ $this->useTransactions = common_config('queue', 'stomp_transactions');
+ $this->useAcks = common_config('queue', 'stomp_acks');
}
/**
@@ -703,13 +706,15 @@ class StompQueueManager extends QueueManager
protected function ack($idx, $frame)
{
- if ($this->useTransactions) {
- if (empty($this->transaction[$idx])) {
- throw new Exception("Tried to ack but not in a transaction");
+ if ($this->useAcks) {
+ if ($this->useTransactions) {
+ if (empty($this->transaction[$idx])) {
+ throw new Exception("Tried to ack but not in a transaction");
+ }
+ $this->cons[$idx]->ack($frame, $this->transaction[$idx]);
+ } else {
+ $this->cons[$idx]->ack($frame);
}
- $this->cons[$idx]->ack($frame, $this->transaction[$idx]);
- } else {
- $this->cons[$idx]->ack($frame);
}
}
diff --git a/lib/util.php b/lib/util.php
index a7f43b5d4..96d21bc59 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -1388,6 +1388,55 @@ function common_valid_tag($tag)
return false;
}
+/**
+ * Determine if given domain or address literal is valid
+ * eg for use in JIDs and URLs. Does not check if the domain
+ * exists!
+ *
+ * @param string $domain
+ * @return boolean valid or not
+ */
+function common_valid_domain($domain)
+{
+ $octet = "(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])";
+ $ipv4 = "(?:$octet(?:\.$octet){3})";
+ if (preg_match("/^$ipv4$/u", $domain)) return true;
+
+ $group = "(?:[0-9a-f]{1,4})";
+ $ipv6 = "(?:\[($group(?::$group){0,7})?(::)?($group(?::$group){0,7})?\])"; // http://tools.ietf.org/html/rfc3513#section-2.2
+
+ if (preg_match("/^$ipv6$/ui", $domain, $matches)) {
+ $before = explode(":", $matches[1]);
+ $zeroes = $matches[2];
+ $after = explode(":", $matches[3]);
+ if ($zeroes) {
+ $min = 0;
+ $max = 7;
+ } else {
+ $min = 1;
+ $max = 8;
+ }
+ $explicit = count($before) + count($after);
+ if ($explicit < $min || $explicit > $max) {
+ return false;
+ }
+ return true;
+ }
+
+ try {
+ require_once "Net/IDNA.php";
+ $idn = Net_IDNA::getInstance();
+ $domain = $idn->encode($domain);
+ } catch (Exception $e) {
+ return false;
+ }
+
+ $subdomain = "(?:[a-z0-9][a-z0-9-]*)"; // @fixme
+ $fqdn = "(?:$subdomain(?:\.$subdomain)*\.?)";
+
+ return preg_match("/^$fqdn$/ui", $domain);
+}
+
/* Following functions are copied from MediaWiki GlobalFunctions.php
* and written by Evan Prodromou. */