Revision: 46929
Author: mkroetzsch
Date: 2009-02-06 17:27:15 +0000 (Fri, 06 Feb 2009)
Log Message:
-----------
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: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_URI.php
===================================================================
--- trunk/extensions/SemanticMediaWiki/includes/SMW_DV_URI.php 2009-02-06
17:04:44 UTC (rev 46928)
+++ trunk/extensions/SemanticMediaWiki/includes/SMW_DV_URI.php 2009-02-06
17:27:15 UTC (rev 46929)
@@ -42,8 +42,9 @@
protected function parseUserValue($value) {
wfLoadExtensionMessages('SemanticMediaWiki');
$value = trim($value);
+ $this->m_url = '';
+ $this->m_value = '';
if ($value!='') { //do not accept empty strings
- $this->m_value = $value;
switch ($this->m_mode) {
case SMW_URI_MODE_URI: case
SMW_URI_MODE_ANNOURI:
$parts = explode(':', $value, 2); //
try to split "schema:rest"
@@ -112,9 +113,10 @@
$this->addError(wfMsgForContent('smw_baduri', $value));
break;
}
- $this->m_url = 'mailto:' .
rawurlencode($value);
+ $this->m_url = 'mailto:' .
str_replace(array('%3A','%2F','%23','%40','%3F','%3D','%26','%25'),
array(':','/','#','@','?','=','&','%'),rawurlencode($value));
$this->m_uri = $this->m_url;
}
+ $this->m_value = $this->m_uri;
} else {
$this->addError(wfMsgForContent('smw_emptystring'));
}
@@ -127,11 +129,20 @@
protected function parseDBkeys($args) {
$this->m_value = $args[0];
+ $this->m_uri = $this->m_value;
$this->m_caption = $this->m_value;
if ($this->m_mode == SMW_URI_MODE_EMAIL) {
- $this->m_url = 'mailto:' . $this->m_value;
+ $this->m_url = $this->m_value;
} else {
- $this->m_url = $this->m_value;
+ $parts = explode(':', $this->m_value, 2); // try to
split "schema:rest"
+ global $wgUrlProtocols;
+ $this->m_url = '';
+ foreach ($wgUrlProtocols as $prot) { // only set URL if
wiki-enabled protocol
+ if ( ($prot == $parts[0] . ':') || ($prot ==
$parts[0] . '://') ) {
+ $this->m_url = $this->m_value;
+ break;
+ }
+ }
}
$this->m_uri = $this->m_url;
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs