Page MenuHomePhabricator

Imagemap # comments prevent linking to sections
Closed, ResolvedPublic

Description

Author: dherding

Description:
The imagemap extension allows adding links using the hash character (#).
However, this hash character is required to create links to page sections.

For example, [[de:Vorlage:Neutralität]] (the German NPOV template) has an image
that should link to the #{{PAGENAME}} subsection of the NPOV page. This is
impossible to realize using imagemaps.

The solution is to remove the feature to add comments after a hash. From a
usability point of view, it is a bad idea anyway. The usual way of adding
comments is embedding them into <!-- HTML comments -->. It is confusing to have
another comment syntax here.


Version: unspecified
Severity: normal
URL: http://de.wikipedia.org/w/index.php?title=Vorlage:Neutralit%C3%A4t&oldid=27520397

Details

Reference
bz8917

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:36 PM
bzimport added a project: ImageMap.
bzimport set Reference to bz8917.
bzimport added a subscriber: Unknown Object (MLST).

anna.h.bauer wrote:

Yes, it is inconvenient to change the way of adding comments. But it is not
acceptable not to be able to do links to sections in articles.

jan-ake wrote:

quick and dirty fix for using # to link to a section in an article

The # seems to be removed when you use escapeLocalURL() but not when you use
escapeFullURL(). Bug or on purpose in escapeLocalURL() ?

Attached:

Fixed with r21299 by adding getFragmentForURL()

Please note, that r21299 will fix links like [[Page#section]].

Links like [[Page#{{PAGENAME}}]] are still not possible, this is bug 2257:
Template parameters unavailable to parser hooks

dherding wrote:

Instead of adding workarounds: What about my proposal to get rid of the #
comment syntax altogether, to make the comment syntax more consistent and thus
understandable?

This patch is not a workaround. It solves the problem with links to sections.
Links like [[Page#{{PAGENAME}}]] are a complete different problem, nothing to do
with any kind of comment style.

Any line with '#' as _first_ character is filtered out at start of parsing the
<imagemap> section.

The fix looks kind of lame to me; IMHO the fix belongs upstream in
Title::getLocalURL().

Some other code would have to be modified to avoid double-fragments, though, and
there might be some other issues, so it should be checked.

Title::getLocalURL()/escapeLocalURL is described explicitly with "Get a URL with
no fragment or server name."

We could use Title::getFullURL()/escapeFullURL instead: "Get an HTML-escaped
version of the URL form, suitable for using in a link, including the server name
and fragment"

Should we? It works, have tested. Double-fragment seems to be no problem in both
variants, the second # in a link will be urlencoded.

Yes but that makes no sense. Why the hell would we ever want the url *with* the
path but *without* the fragment? The documentation was probably added after.

ayg wrote:

*** Bug 9885 has been marked as a duplicate of this bug. ***

Gilles raised the priority of this task from Medium to Unbreak Now!.Dec 4 2014, 10:12 AM
Gilles moved this task from Untriaged to Done on the Multimedia board.
Gilles lowered the priority of this task from Unbreak Now! to Medium.Dec 4 2014, 11:21 AM