Modify

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#13077 closed defect (fixed)

BackLinksMacro shows false positives

Reported by: t.williams@… Owned by: t.williams@…
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)

13077_backlinksmacro_fewer_false_positives.diff (2.1 KB) - added by t.williams@… 7 years ago.
Rather naive patch that appears to resolve this issue.

Download all attachments as: .zip

Change History (11)

Changed 7 years ago by t.williams@…

Rather naive patch that appears to resolve this issue.

comment:1 Changed 7 years ago by t.williams@…

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 Changed 7 years ago by Ryan J Ollos

Owner: set to Ryan J Ollos
Status: newaccepted

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.

Last edited 7 years ago by Ryan J Ollos (previous) (diff)

comment:3 Changed 7 years ago by Ryan J Ollos

Resolution: fixed
Status: acceptedclosed

In 16369:

8.0dev: Refine wiki page regex

Patch by t.williams@….

Fixes #13077.

comment:4 Changed 7 years ago by Ryan J Ollos

Owner: changed from Ryan J Ollos to t.williams@…

comment:5 Changed 7 years ago by Ryan J Ollos

#12619 closed as a duplicate.

comment:6 Changed 7 years ago by t.williams@…

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 in reply to:  2 Changed 7 years ago by t.williams@…

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 Changed 7 years ago by Ryan J Ollos

Thanks for spotting, I incorrectly rebase the patch. Would you please try the latest?

comment:9 Changed 7 years ago by Ryan J Ollos

In 16377:

8.0dev: Add changes unintentionally omitted from r16369

Refs #13077.

comment:10 in reply to:  8 Changed 7 years ago by t.williams@…

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.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain t.williams@….
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.