Last modified: 2011-05-01 19:20:57 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T29916, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 27916 - Don't prefix wgServer in mw.util.wikiGetlink
Don't prefix wgServer in mw.util.wikiGetlink
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
JavaScript (Other open bugs)
1.18.x
All All
: High enhancement (vote)
: ---
Assigned To: Krinkle
https://secure.wikimedia.org/wikibook...
: patch, patch-need-review
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-03-07 13:09 UTC by Helder
Modified: 2011-05-01 19:20 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Enhanced version (627 bytes, application/javascript)
2011-03-07 13:09 UTC, Helder
Details
Patch by mybugs.mail@gmail.com (808 bytes, patch)
2011-05-01 18:55 UTC, DieBuche
Details
Remove the check and the wgServer prefix from mw.util.wikiGetlink (749 bytes, patch)
2011-05-01 18:57 UTC, Krinkle
Details

Description Helder 2011-03-07 13:09:22 UTC
Created attachment 8258 [details]
Enhanced version

Sometimes it is needed to create local links in a wiki and with the current implementation of mw.util.wikiGetlink, the url includes the server name. Consequently, the CSS matched by

 div#content a[href ^="https://"] {...}

will add the lock icon[1] on links whose href is defined by the function (for an example, see the above url). 

It would be useful to be able to specify whether the link should be local or not. In the attached file there is an example of how this could be done.

[1] https://secure.wikimedia.org/skins-1.17/vector/images/lock-icon.png
Comment 1 Krinkle 2011-05-01 18:51:28 UTC
Some browsers (IE if I recall correctly) internally interpret href attributes absolutely.

Meaning (atleast with javascript selectors) that href^="http" would match internal links as well.
I don't know if this is the case for real CSS as well, should be easy to test.

However, what about removing wgServer prefix all together ? Do we need it ?
Comment 2 DieBuche 2011-05-01 18:55:56 UTC
Created attachment 8477 [details]
Patch by mybugs.mail@gmail.com

make patch from attachment
Comment 3 Krinkle 2011-05-01 18:57:05 UTC
Created attachment 8478 [details]
Remove the check and the wgServer prefix from mw.util.wikiGetlink

The check is not needed, if wgArticlePath is undefined there's probably a much bigger issue.

The wgServer doesn't need to be prefixed to the link (if someone really needs it (ie. external tools using the script and somehow defining wgServer in mw.config) they can surely prefix wgServer themselfs.

In most if not all cases this is used to create anchor tags, which are interprated by browsers relatively to the current window location and in some browsers it even auto-prefixes the current environment when setting the href/src attribute.
Comment 4 Krinkle 2011-05-01 19:20:57 UTC
Fixed in r87208.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links