Description
The wiki.py parser fails to correctly identify some links. This manifests itself when Page.py calls self.formatter.pagelinks.
Steps to reproduce
Create a page with the following content:
* [:ThisLinkFails:Not Included in pagelinks return data] * ["ThisLinkWorks"]
Examine the contents of data/pages/pagename-here/cache/pagelinks. You'll see ThisLinkWorks but not ThisLinkFails.
Example
Details
MoinMoin Version |
1.3.4 |
OS and Version |
Windows XP SP2 and also Fedora 3 |
Python Version |
2.3 |
Server Setup |
Apache 2.0.48 CGI |
Server Details |
n/a |
Workaround
None
Proposed fix
--- wiki.py.orig 2005-05-24 16:50:13.000000000 -0700 +++ wiki.py 2005-06-01 13:42:12.009685523 -0700 @@ -149,7 +149,16 @@ else: url, text = url_and_text - url = url[5:] # remove "wiki:" + # keep track of whether this is a self-reference, so links + # are always shown even the page doesn't exist. + is_self_reference = 0 + url2 = url.lower() + if url2.startswith('wiki:self:'): + url = url[10:] # remove "wiki:self:" + is_self_reference = 1 + elif url2.startswith('wiki:'): + url = url[5:] # remove "wiki:" + if text is None: tag, tail = wikiutil.split_wiki(url) if tag: @@ -160,7 +169,7 @@ elif config.allow_subpages and url.startswith(wikiutil.CHILD_PREFIX): # fancy link to subpage [wiki:/SubPage text] return self._word_repl(url, text) - elif Page(self.request, url).exists(): + elif is_self_reference or Page(self.request, url).exists(): # fancy link to local page [wiki:LocalPage text] return self._word_repl(url, text)
June 1, 2005 - EricJohnson - Minor update to patch so that page references to non-existent pages still show with the custom text.
The patch may be correct but interwiki function is already too long. self interwiki links should be handled in a separate function. Adding more code to this already hard to understand function is wrong. -- NirSoffer 2005-06-01 21:12:50
Nir, how could you confirm a bug that has been fixed for weeks?
- I reproduced it my test wiki, running last patch. How can you confirm a fix on a bug without testing it?
The bug still here, probably the new way interwikilinks are detected, by checking the intermap file.
- I cannot reproduce it locally.
Try here: http://nirs.dyndns.org/main/WikiSandBox
Although I agree with Nir that the linking code in Moin is already too complex, the right time to fix (rewrite) it is not now, but in 2.0. I just applied the proposed fix and this site currently runs on the patched code.
Plan
Fix may require some refactoring of wiki parser, very fragile code.
- Priority: medium, break linkto search
Assigned to: ThomasWaldmann
- Status: testing patch, will be commited soon to moin 1.5 branch