r46929 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46928‎ | r46929 | r46930 >
Date:17:27, 6 February 2009
Author:mkroetzsch
Status:deferred
Tags:
Comment:
fixed storing of URLs so that they always come out the way they went in; prevent over-escaping of some symbols when escaping a whole URL-string,
properly check whether protocol supports linking when retrieving values from database
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_URI.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_URI.php
@@ -42,8 +42,9 @@
4343 protected function parseUserValue($value) {
4444 wfLoadExtensionMessages('SemanticMediaWiki');
4545 $value = trim($value);
 46+ $this->m_url = '';
 47+ $this->m_value = '';
4648 if ($value!='') { //do not accept empty strings
47 - $this->m_value = $value;
4849 switch ($this->m_mode) {
4950 case SMW_URI_MODE_URI: case SMW_URI_MODE_ANNOURI:
5051 $parts = explode(':', $value, 2); // try to split "schema:rest"
@@ -112,9 +113,10 @@
113114 $this->addError(wfMsgForContent('smw_baduri', $value));
114115 break;
115116 }
116 - $this->m_url = 'mailto:' . rawurlencode($value);
 117+ $this->m_url = 'mailto:' . str_replace(array('%3A','%2F','%23','%40','%3F','%3D','%26','%25'), array(':','/','#','@','?','=','&','%'),rawurlencode($value));
117118 $this->m_uri = $this->m_url;
118119 }
 120+ $this->m_value = $this->m_uri;
119121 } else {
120122 $this->addError(wfMsgForContent('smw_emptystring'));
121123 }
@@ -127,11 +129,20 @@
128130
129131 protected function parseDBkeys($args) {
130132 $this->m_value = $args[0];
 133+ $this->m_uri = $this->m_value;
131134 $this->m_caption = $this->m_value;
132135 if ($this->m_mode == SMW_URI_MODE_EMAIL) {
133 - $this->m_url = 'mailto:' . $this->m_value;
 136+ $this->m_url = $this->m_value;
134137 } else {
135 - $this->m_url = $this->m_value;
 138+ $parts = explode(':', $this->m_value, 2); // try to split "schema:rest"
 139+ global $wgUrlProtocols;
 140+ $this->m_url = '';
 141+ foreach ($wgUrlProtocols as $prot) { // only set URL if wiki-enabled protocol
 142+ if ( ($prot == $parts[0] . ':') || ($prot == $parts[0] . '://') ) {
 143+ $this->m_url = $this->m_value;
 144+ break;
 145+ }
 146+ }
136147 }
137148 $this->m_uri = $this->m_url;
138149 }

Status & tagging log