From bdab2c5faf8a2b311debce0b724a0b2df02aa60c Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Sun, 20 Sep 2009 06:25:14 -0400
Subject: [PATCH] - small code improvements
---
program/include/rcube_string_replacer.php | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/program/include/rcube_string_replacer.php b/program/include/rcube_string_replacer.php
index 064a723..2625fdf 100644
--- a/program/include/rcube_string_replacer.php
+++ b/program/include/rcube_string_replacer.php
@@ -74,7 +74,7 @@
$i = -1;
$scheme = strtolower($matches[1]);
- if ($scheme == 'http://' || $scheme == 'https://' || $scheme == 'ftp://') {
+ if (preg_match('!^(http|ftp|file)s?://!', $scheme)) {
$url = $matches[1] . $matches[2];
$i = $this->add(html::a(array('href' => $url, 'target' => '_blank'), Q($url)));
}
@@ -83,7 +83,8 @@
$i = $this->add($m[1] . html::a(array('href' => 'http://' . $url, 'target' => '_blank'), Q($url)));
}
- return $i >= 0 ? $this->get_replacement($i) : '';
+ // Return valid link for recognized schemes, otherwise, return the unmodified string for unrecognized schemes.
+ return $i >= 0 ? $this->get_replacement($i) : $matches[0];
}
/**
--
Gitblit v1.9.1