From 32fe4e71311225eb8a58f85c7ac00b14da9ca1d4 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 9 Jul 2007 10:24:51 +0200 Subject: [PATCH] Handle URL field RFC conform RCF 2079 specifies a value that contains a URL followed by white space and then a human readable string. The template now supports that. darcs-hash:20070709082451-6e07b-571a3a7111aadf0b0b3bee7fa57c063bdc48fea9.gz --- inc/smarty/plugins/modifier.http.php | 13 ++++++++----- templates/entry_show.tpl | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/inc/smarty/plugins/modifier.http.php b/inc/smarty/plugins/modifier.http.php index a3fffbc..ecb52e7 100644 --- a/inc/smarty/plugins/modifier.http.php +++ b/inc/smarty/plugins/modifier.http.php @@ -10,9 +10,7 @@ * Smarty plugin * * Type: modifier - * Name: noteparser * Date: 2007-06-19 - * Purpose: Add the http:// protocol if missing * Example: {$foo|http} * @author Andreas Gohr * @param string @@ -21,11 +19,16 @@ function smarty_modifier_http($string){ if(!$string) return ''; - if(!preg_match('#^\w+://#',$string)){ - $string = 'http://'.$string; + list($url,$name) = explode(' ',$string,2); + + + if(!preg_match('#^\w+://#',$url)){ + $url = 'http://'.$url; } - return $string; + if(!$name) $name = $url; + + return ''.htmlspecialchars($name).''; } /* vim: set expandtab: */ diff --git a/templates/entry_show.tpl b/templates/entry_show.tpl index 18cc419..25c2b61 100644 --- a/templates/entry_show.tpl +++ b/templates/entry_show.tpl @@ -141,7 +141,7 @@ {if $entry.url} {$lang.url}: - {$entry.url|h} + {$entry.url|http} {/if} {if $entry.mail} -- 2.39.5