#13077 closed defect (fixed)
BackLinksMacro shows false positives
| Reported by: | Owned by: | ||
|---|---|---|---|
| Priority: | normal | Component: | BackLinksMacro |
| Severity: | normal | Keywords: | patch |
| Cc: | Trac Release: | 1.2 |
Description
The algorithm used by the BackLinksMacro to determine where there is a back link appears to be somewhat naive using the regex \bPageName\b. In most cases this is adequate, but if you don't always use the CamelCase naming convention for your wiki pages then it often reports false positives.
e.g. if you have a page called "Reports" then any use of the text "Reports" on other wiki pages is going to be listed as a back link.
Attachments (1)
Change History (11)
Changed 9 years ago by
| Attachment: | 13077_backlinksmacro_fewer_false_positives.diff added |
|---|
comment:1 Changed 9 years ago by
The attached patch offers one solution to the problem.
Please note it also includes an update to the Trac 1.x database API, see #13076.
comment:2 follow-up: 7 Changed 9 years ago by
| Owner: | set to Ryan J Ollos |
|---|---|
| Status: | new → accepted |
Looks like an improvement so I'll go ahead and commit it. You might be able to improve further by using regex defined in browser:tags/trac-1.2/trac/wiki/api.py#L350.
comment:4 Changed 9 years ago by
| Owner: | changed from Ryan J Ollos to t.williams@… |
|---|
comment:6 Changed 9 years ago by
Hi Ryan, it might be deliberate but you don't seem to have accepted the whole patch and as a result the code now contains the following unused function:
def sql_search_pattern(backlinks_page): if is_camel_case(backlinks_page): return backlinks_page else: return r'wiki:%s' % backlinks_page
comment:7 Changed 9 years ago by
Replying to Ryan J Ollos:
Looks like an improvement so I'll go ahead and commit it. You might be able to improve further by using regex defined in browser:tags/trac-1.2/trac/wiki/api.py#L350.
I knew that code must exist somewhere but couldn't find it with a brief check. I'm not sure I'm going to revisit at this time because what I provided does the job for me.
comment:8 follow-up: 10 Changed 9 years ago by
Thanks for spotting, I incorrectly rebase the patch. Would you please try the latest?
comment:10 Changed 9 years ago by
Replying to Ryan J Ollos:
Thanks for spotting, I incorrectly rebase the patch. Would you please try the latest?
Tested very briefly and seems to work.



Rather naive patch that appears to resolve this issue.