Modify

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#11443 closed defect (fixed)

Allow non-project relative (absolute) links again.

Reported by: ryank-inovonics Owned by: Ryan J Ollos
Priority: normal Component: NavAddPlugin
Severity: normal Keywords:
Cc: Trac Release: 1.0

Description

With the fix for #940, this plugin only allowed links relative to the Trac environment to be used. While this is handy for multiple instance setups, it does prevent the use of absolute links to resources outside the Trac environment.

The attached patch checks the provided href to see if it starts with https:, http:, or /. If it does then the URL is used in the nav bar item directly. Otherwise it is left as a link relative to the Trac environment.

Attachments (1)

NavAdd.diff (830 bytes) - added by ryank-inovonics 4 years ago.
Restore support for absolute URLs.

Download all attachments as: .zip

Change History (11)

Changed 4 years ago by ryank-inovonics

Attachment: NavAdd.diff added

Restore support for absolute URLs.

comment:1 Changed 4 years ago by Ryan J Ollos

Owner: changed from Michael Renzmann to Ryan J Ollos
Status: newassigned

comment:2 Changed 4 years ago by Ryan J Ollos

For the case that the href starts with /, do you treat it as relative to the network location (e.g. http://www.myserver.com)?

For example, if the base of a project is /proj1, then wiki/WikiStart maps to /proj1/wiki/WikiStart, but an href starting with / would need to start with the project name (.e.g /proj2)?

comment:3 Changed 4 years ago by ryank-inovonics

That is correct, some examples for a Trac installed at https://www.myserver.com/trac/:

hrefLink in page source.Link as displayed/used by web browser.
/reviewboard//reviewboard/https://www.myserver.com/reviewboard/
report/43/trac/report/43https://trac.inovonics.com/trac/report/43
https://www.other.com/https://www.other.com/https://www.other.com/

I chose this logic as it let you specify links relative to the Trac instance, the server hosting Trac instance(s), or an absolute location with a single config value.

comment:4 Changed 4 years ago by Ryan J Ollos

The rules you suggest make sense. The changes would be inconsistent with the rules used for the MenusPlugin, but that plugin should probably be changed since it doesn't allow for links on the same base URL without specifying the full URL.

comment:5 Changed 4 years ago by Ryan J Ollos

Status: assignedaccepted

comment:6 Changed 4 years ago by Ryan J Ollos

Your suggestions agree with the documentation for [mainnav] and [metanav] at TracNavigation. However, I found that similar problems exist in Trac: trac:#11432.

comment:7 Changed 4 years ago by Ryan J Ollos

Resolution: fixed
Status: acceptedclosed

In 13554:

0.3: An href starting with a / is relative to the base URL, and absolute URLs are treated as such. Fixes #11443.

Removed some unused code. Thanks to ryank-inovonics for the patch.

Version 2, edited 4 years ago by Ryan J Ollos (previous) (next) (diff)

comment:8 Changed 4 years ago by Ryan J Ollos

If you have a chance to test out the latest code and report back whether it is working for you, that would be appreciated.

comment:9 Changed 4 years ago by Ryan J Ollos

Documentation updated.

comment:10 Changed 4 years ago by ryank-inovonics

Works great! Thanks.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted.

Add Comment


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

 
Note: See TracTickets for help on using tickets.