[cvsspam-devel] wikisub over multiple matches

David Holroyd dave at badgers-in-foil.co.uk
Tue Dec 19 08:52:39 UTC 2006


Hey,

On Wed, Dec 13, 2006 at 02:33:41PM +0200, Elan Ruusam?e wrote:
> wouldn't it be reasonable if each [[wikiword]] is expanded to wiki link 
> instead the default greedy match? probably this applies to all link patterns.
> 
> currently:
> - use <a href="wikilink?SCRIPT_NAME]] over [[PHP_SELF">[[SCRIPT_NAME]] over 
> [[PHP_SELF]]</a>
> 
> i'd expect:
> - use <a href="wikilink?SCRIPT_NAME">[[SCRIPT_NAME]] over <a 
> href="wikilink?PHP_SELF">[[PHP_SELF]]</a>

I've changed the wikiSub to use a non greedy match,

wikiSub = proc { |match| 
  match =~ /\[\[(.*?)\]\]/
  raw = $1
  "<a href=\"#{$wikiURL.sub(/%s/, urlEncode(raw))}\">[[#{raw}]]</a>"
}
      
Hopefully that will fix this issue.  The other matches constrain the
characters in '+' / '*' so that they wont match the terminator,
therefore I think this is the only one where a runaway greedy match can
happen.


thanks for letting me know!
dave

-- 
http://david.holroyd.me.uk/



More information about the cvsspam-devel mailing list