Page MenuHomePhabricator

Use "&" instead of "\u0026" for urls in JS redirect pages (for easier copy/paste)
Closed, ResolvedPublic

Description

Since T73200: Support redirects in JavaScriptContent was fixed, when I move a JS page and allow MW to create a redirect, it is created with a code such as

/* #REDIRECT */mw.loader.load("//pt.wikipedia.org/w/index.php?title=Usu%C3%A1rio(a):He7d3r/common.js\u0026action=raw\u0026ctype=text/javascript");

However, this usage of \u0026 makes it hard to copy the URL directly from the code, because we have to replace all \u0026 by & before pasting it somewhere.

Event Timeline

He7d3r raised the priority of this task from to Needs Triage.
He7d3r updated the task description. (Show Details)
He7d3r subscribed.
Aklapper triaged this task as Lowest priority.Jul 30 2015, 11:09 AM

This is automatically done by Xml::encodeJsCall -> Xml::encodeJsVar -> FormatJson::encode( ..., ..., FormatJson::UTF8_OK ). I don't know if there is a specific reason for it...

This is automatically done by Xml::encodeJsCall -> Xml::encodeJsVar -> FormatJson::encode( ..., ..., FormatJson::UTF8_OK ). I don't know if there is a specific reason for it...

Xml::escapeJsString() has encoded ampersands since 1.8 (rSVN15871 / rMW584c456a942fc8ae). Presumably, the reason is that within script elements in XHTML documents, ampersands must be encoded unless inside a CDATA section.

When I made Xml::encodeJsVar() instead use FormatJson::encode(), I grepped extensions and found a few that did not use Html::inlineScript(), so I decided to have FormatJson encode ampersands, as Xml::escapeJsString() had already done.

Change 267174 had a related patch set uploaded (by IoannisKydonis):
Use "&" instead of "\u0026".

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

Bawolff renamed this task from Use "&" instead of "\u0026" for easily copying URLs in JS pages to Use "&" instead of "\u0026" for urls in JS redirect pages (for easier copy/paste).Sep 9 2016, 4:14 AM
Bawolff set Security to None.

Change 267174 abandoned by Thiemo Kreuz (WMDE):
Use "&" instead of "\u0026".

Reason:
This patch is incomplete and does not even touch the one line of code that creates these encoded ampersands, as explained by Krinkle in the last comment. Better start over, as a 2 years old incomplete draft won't help fixing the issue.

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

@IoannisKydonis are you still planning to work on this? At JavaScriptContentHandler::makeRedirectContent, using $url = str_replace( "\u0026", "&", $url ); should do the trick

Krinkle added a subscriber: daniel.
Krinkle unsubscribed.

Tagging CPT as likely steward for the content handler. This is a low-priority enhancement to improve usability of wiki pages that are JS redirects. Probably won't reach the surface of any backlog, but tagging for visibility and tracking in case a volunteer has questions about the code and (later) for code review.

Change 566120 had a related patch set uploaded (by Ammarpad; owner: Ammarpad):
[mediawiki/core@master] Do not encode & in JS redirect content

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

I saw a renewed interest for this on enwiki, so I made the change

Change 566120 abandoned by Ammarpad:
[mediawiki/core@master] Do not encode & in JS redirect content

Reason:

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

Ammarpad subscribed.
Ammarpad unsubscribed.

Change 837202 had a related patch set uploaded (by Legoktm; author: Legoktm):

[mediawiki/core@master] Do not encode `&` in JavaScript redirect content

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

Taking on as closely related to ResourceLoader and benefiting general usability of JavaScript content editing on-wiki.

Change 970467 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/core@master] content: Improve roundtrip tests for JavaScriptContent

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

Change 837202 merged by jenkins-bot:

[mediawiki/core@master] content: Stop encoding `&` in JavaScript redirect content

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