--- classTextile.php.orig 2009-02-05 18:54:32.000000000 -0800 +++ classTextile.php 2009-02-05 20:51:54.000000000 -0800 @@ -742,14 +742,15 @@ class Textile { return preg_replace_callback('/ (^|(?<=[\s>.$pnct\(])|[{[]) # $pre - " # start - (' . $this->c . ') # $atts - ([^"]+?) # $text - (?:\(([^)]+?)\)(?="))? # $title + " # start + (' . $this->c . ') # $atts + ([^"]+?) # $text + (?:\(([^)]+?)\)(?="))? # $title + (?:\<([^>]+?)\>(?="))? # $URLrel ": - ('.$this->urlch.'+?) # $url - (\/)? # $slash - ([^\w\/;]*?) # $post + ('.$this->urlch.'+?) # $url + (\/)? # $slash + ([^\w\/;]*?) # $post ([\]}]|(?=\s|$|\))) /x', array(&$this, "fLink"), $text); } @@ -757,11 +758,11 @@ class Textile // ------------------------------------------------------------- function fLink($m) { - list(, $pre, $atts, $text, $title, $url, $slash, $post, $tail) = $m; + list(, $pre, $atts, $text, $title, $URLrel, $url, $slash, $post, $tail) = $m; $atts = $this->pba($atts); $atts .= ($title != '') ? ' title="' . $this->encode_html($title) . '"' : ''; - + if (!$this->noimage) $text = $this->image($text); @@ -770,7 +771,18 @@ class Textile $url = $this->shelveURL($url.$slash); - $out = 'rel . '>' . trim($text) . '' . $post; + //handle rels intelligently + if (!empty($URLrel)) { + $URLrel = trim(strip_tags($URLrel)); //protect yourself from xss + // if class-wide rel exists, append these rels + if ($this->rel) { + $atts .= preg_replace('/"$/',' '.$URLrel.'"',$this->rel); + } + else { + $atts .= ' rel="' . $URLrel . '"'; + } + } + $out = '' . trim($text) . '' . $post; if (($pre and !$tail) or ($tail and !$pre)) $out = $pre.$out.$tail; @@ -848,17 +860,19 @@ class Textile function image($text) { return preg_replace_callback("/ - (?:[[{])? # pre - \! # opening ! - (\<|\=|\>)? # optional alignment atts - ($this->c) # optional style,class atts - (?:\. )? # optional dot-space - ([^\s(!]+) # presume this is the src - \s? # optional space - (?:\(([^\)]+)\))? # optional title - \! # closing - (?::(\S+))? # optional href - (?:[\]}]|(?=\s|$|\))) # lookahead: space or end of string + (?:[[{])? # pre + \! # opening ! + (\<|\=|\>)? # optional alignment atts + ($this->c) # optional style,class atts + (?:\. )? # optional dot-space + ([^\s(!]+) # presume this is the src + \s? # optional space + (?:\(([^\)]+)\))? # optional title + \s? # optional space + (?:\<([^\>]+)\>)? # optional title + \! # closing ! + (?::(\S+))? # optional href + (?:[\]}]|(?=\s|$|\))) # lookahead: space or end of string /x", array(&$this, "fImage"), $text); } @@ -868,18 +882,22 @@ class Textile list(, $algn, $atts, $url) = $m; $atts = $this->pba($atts); $atts .= ($algn != '') ? ' align="' . $this->iAlign($algn) . '"' : ''; - $atts .= (isset($m[4])) ? ' title="' . $m[4] . '"' : ''; - $atts .= (isset($m[4])) ? ' alt="' . $m[4] . '"' : ' alt=""'; + $atts .= (isset($m[4])) ? ' alt="' . $m[4] . '"' : ' alt=""'; + $title = (isset($m[4])) ? ' title="' . $m[4] . '"' : ''; + $atts .= $title; + $size = false; if ($this->isRelUrl($url)) $size = @getimagesize(realpath($this->doc_root.ltrim($url, $this->ds))); if ($size) $atts .= " $size[3]"; - $href = (isset($m[5])) ? $this->shelveURL($m[5]) : ''; - $url = $this->shelveURL($url); + $URLrel = (isset($m[5])) ? ' rel="' . $this->encode_html($m[5]) . '"' : ''; + $href = (isset($m[6])) ? $this->shelveURL($m[6]) : ''; + $url = $this->shelveURL($url); + $out = array( - ($href) ? '' : '', + ($href) ? '' : '', '', ($href) ? '' : '' );