Modify

Opened 9 months ago

Closed 8 months ago

Last modified 8 months ago

#11443 closed defect (fixed)

Allow non-project relative (absolute) links again.

Reported by: ryank-inovonics Owned by: rjollos
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 9 months ago.
Restore support for absolute URLs.

Download all attachments as: .zip

Change History (11)

Changed 9 months ago by ryank-inovonics

Restore support for absolute URLs.

comment:1 Changed 9 months ago by rjollos

  • Owner changed from otaku42 to rjollos
  • Status changed from new to assigned

comment:2 Changed 8 months ago by rjollos

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 8 months 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 8 months ago by rjollos

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 8 months ago by rjollos

  • Status changed from assigned to accepted

comment:6 Changed 8 months ago by rjollos

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 8 months ago by rjollos

  • Resolution set to fixed
  • Status changed from accepted to closed

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.

Last edited 8 months ago by rjollos (previous) (diff)

comment:8 Changed 8 months ago by rjollos

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 8 months ago by rjollos

Documentation updated.

comment:10 Changed 8 months ago by ryank-inovonics

Works great! Thanks.

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.