Page MenuHomePhabricator

Relative links to subpages are treated as links to the mainspace that start with / until after saving
Closed, ResolvedPublic1 Estimated Story Points

Description

Steps to reproduce:

  1. Create a userpage ([[User:Example]]). Create a /Sandbox in your userspace ([[User:Example/Sandbox]]).
  2. Open the userpage in VisualEditor.
  3. Add a relative link to the subpage: /Sandbox. This is easily done by opening the link tool and typing "/Sandbox" into the box.
  4. Note that the resulting link is red, even though you have already created the subpage.
  5. Click the link in the context menu to open it in a new tab. The link opened is to a page in the mainspace: /Sandbox.
  6. Save the page. Notice that the link is now blue, and leads to the subpage.

Expectation: The link in VisualEditor and the link when the page has been saved will lead to the same page.

(Search has the same "problem": if you search for /Sandbox, it will offer to let you create a page with that title, including the initial slash.)

Event Timeline

Whatamidoing-WMF raised the priority of this task from to Needs Triage.
Whatamidoing-WMF updated the task description. (Show Details)
Whatamidoing-WMF renamed this task from Relative links to subpages aren't treated as links to the mainspace that start with / to Relative links to subpages are treated as links to the mainspace that start with / until after saving.Aug 26 2015, 10:35 PM
Whatamidoing-WMF set Security to None.

You are probably thinking of T109599: When inserting an image on a sub-page (Foo/Bar), the target of links in captions link to sibling pages (Foo/Baz) rather than uncle pages (Baz).

Assuming that the 2015-09-01 deployment has reached mediawiki.org by now, then the answer is no: This has not been fixed.

Jdforrester-WMF edited a custom field.
Jdforrester-WMF moved this task from To Triage to Freezer on the VisualEditor board.
janboehme added a project: Parsoid.
janboehme subscribed.

The behaviour seems to have changed. The Wikitext generated does not represent a valid Link at all.

VE produces the following HTML:

<a href="/Subpagelink" rel="mw:WikiLink">Linktext</a>

From that Parsoid now generates the Wikitext

[/Subpagelink Linktext]

which looks like an (also broken, b/c missing another leading slash) protocol relative external link, while I'd expect the following:

[[/Subpagelink|Linktext]]

I can't reproduce the bad link generation, though I agree the not-actually-a-redlink is still happening.

image.png (53×442 px, 8 KB)

interesting. Which parsoid version do you use? I'm on v0.10.0,

I'm using a current checkout of it, so I suppose I have a few months of miscellaneous changes since the 0.10.0 release.

@DLynch ok, there might be something. on wikimedia.org it seems to be working, too. I'll set up a recent version tomorrow and and have a look. Thank you so far!

Well, it's not Parsoid but VisualEditor. I've been using the REL1_32 branch, which produces HTML like

<a href="/Subpagelink" rel="mw:WikiLink">Linktext</a>

I didn't find the exact commit when this behavior changed but a current master checkout gives

<a href=".//Subpage" rel="mw:WikiLink">Linktext</a>

instead, which can be correctly transformed to Wikitext.

@janboehme I'd speculatively point to this commit but can't claim to have actually tested that.

Regardless! Sounds like it degraded for a bit, but we're back to the ticket description being accurate, and the issue just being inaccurate redlinks.

Change 503441 had a related patch set uploaded (by DLynch; owner: DLynch):
[mediawiki/extensions/VisualEditor@master] ApiResponseCache: normalize titles with subpages

https://gerrit.wikimedia.org/r/503441

Typing "/Sandbox" into the link inspector shouldn't create a link to the "Sandbox" subpage of the current page. It should create a link to the page "/Sandbox" in the main namespace. We do not support any other relative link syntaxes supported by MediaWiki (e.g. try "../Sandbox", it refuses to accept it, but [[../Sandbox]] is a valid link in wikitext).

It seems like a Parsoid bug that a link to a page called "/Sandbox" is transformed to [[/Sandbox]] rather than [[:/Sandbox]] (the colon can be used to avoid special handling, like in e.g. [[:Category:Foo]]). I filed a separate task about this: T221028.

.//Foo is pretty dubious as an href. I'd expect ./%2FFoo (if subpages aren't enabled) or ./CurrentPageTitle/Foo (if they are). The base href is always the root of the wiki.

I said it on the other ticket as well, but I suspect that pages which start with a / are probably far less common than subpages, so it'd be a strange case to optimize for...

Change 507841 had a related patch set uploaded (by DLynch; owner: DLynch):
[mediawiki/extensions/VisualEditor@master] MWInternalLinkAnnotationWidget: adjust the input for relative links to subpages

https://gerrit.wikimedia.org/r/507841

Change 507841 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] MWInternalLinkAnnotationWidget: adjust the input for relative links to subpages

https://gerrit.wikimedia.org/r/507841

Change 503441 abandoned by DLynch:
ApiResponseCache: normalize titles with subpages

Reason:
Supplanted by Idf9dc3fafab0e9c809eaf6c523c80da57577bb61

https://gerrit.wikimedia.org/r/503441