This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 26338 - Limit query encoding override to http/https
Summary: Limit query encoding override to http/https
Status: RESOLVED WORKSFORME
Alias: None
Product: WHATWG
Classification: Unclassified
Component: URL (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: Unsorted
Assignee: Anne
QA Contact: sideshowbarker+urlspec
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-15 18:28 UTC by Simon Sapin
Modified: 2015-06-17 15:33 UTC (History)
3 users (show)

See Also:
annevk: needinfo? (simon.sapin)


Attachments

Description Simon Sapin 2014-07-15 18:28:53 UTC
The spec currently says, in the query state of the URL parser:

> If url's relative flag is unset or url's scheme is either "ws" or "wss", set encoding override to utf-8.

The relative flag is only set of "ftp", "file", "gopher", "http", "https", "ws", and "wss" schemes. The query does not apply to "ftp", "file", or "gopher". This leaves only "http" and "https" schemes where the encoding override is relevant.

Rather than adding all future relative schemes to the blacklist for this quirk, I suggest whitelisting. Change the quoted text to:

> If url's scheme is neither "http" nor "https", set encoding override to utf-8.
Comment 1 Anne 2014-07-28 13:27:34 UTC
Why does query not apply to those schemes? You can submit forms within file URLs for instance.
Comment 2 Simon Sapin 2014-07-28 14:43:41 UTC
You can, but the query string is not transmitted over the wire for the server-side to process. Or, for the file scheme, there isn’t any server-side software that could process the query string.
Comment 3 Anne 2014-07-28 14:46:21 UTC
Isn't client-side equally affected?
Comment 4 Simon Sapin 2014-07-28 15:12:07 UTC
decodeURIComponent() always uses UTF-8, so using any other character encoding for percent-encoding seems more likely to cause mojibake when the query string is used on the client-side.

http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.3
Comment 5 Anne 2014-07-28 15:25:34 UTC
Sure, but what about compatibility? Or are you saying this is how it works today?
Comment 6 admin 2015-02-13 16:08:31 UTC
// ==UserScript==
// @name          Travian UI treak
// @namespace     http://userstyles.org
// @description	  Travian UI treak with T3B ML&CN
// @author        gogonkt
// @homepage      http://userstyles.org/styles/30248
// @include       http://travian.tw/*
// @include       https://travian.tw/*
// @include       http://*.travian.tw/*
// @include       https://*.travian.tw/*
// @run-at        document-start
// ==/UserScript==
(function() {
var css = "#side_navi{\n   width: 120px !important;\n   float: right !important;}\n\n#side_info{\n   width: 380px !important;}\n\n#tasklisttable_wrapper{\n  padding: 0px !important;\n  top: 535px !important; left: 30px !important; position: fixed !important;}\n\ntable>caption,#tasklisttable>tbody{\n  display: none !important;}\n\n#res{\n  left: 0px !important;}\n\n#mid{\n  background: none !important;}\n\ntable tbody td{\n  padding-left: 0px !important;}";
if (typeof GM_addStyle != "undefined") {
	GM_addStyle(css);
} else if (typeof PRO_addStyle != "undefined") {
	PRO_addStyle(css);
} else if (typeof addStyle != "undefined") {
	addStyle(css);
} else {
	var node = document.createElement("style");
	node.type = "text/css";
	node.appendChild(document.createTextNode(css));
	var heads = document.getElementsByTagName("head");
	if (heads.length > 0) {
		heads[0].appendChild(node); 
	} else {
		// no head yet, stick it whereever
		document.documentElement.appendChild(node);
	}
}
})();
Comment 7 Anne 2015-06-17 15:33:01 UTC
This is now restricted to a whitelist, the special URLs minus ws/wss.