Patchwork hgweb: override the charset attribute in the http request

login
register
mail settings
Submitter elson.wei@gmail.com
Date April 10, 2014, 7:12 a.m.
Message ID <2fccd923044071bb78ae.1397113972@ElsonWei-NB.PrimeVOLT>
Download mbox | patch
Permalink /patch/4276/
State Accepted
Commit 55543ee545abc53069aa565c1a9f8e88a89a01bf
Headers show

Comments

elson.wei@gmail.com - April 10, 2014, 7:12 a.m.
# HG changeset patch
# User Wei, Elson <elson.wei@gmail.com>
# Date 1397113932 -28800
#      Thu Apr 10 15:12:12 2014 +0800
# Node ID 2fccd923044071bb78ae03aa5ddfbab358564514
# Parent  dbf0fa39a5b81a226a8953e91c7d5a151d453e06
hgweb: override the charset attribute in the http request

The default http request character set is UTF-8. If the message is not encoded
in UTF-8, such as big5, it cannot be shown correctly. The 'charset' is
overridden by the root document's, such that the user can select the proper
encoding in the browser.
Mads Kiilerich - April 10, 2014, 12:13 p.m.
On 04/10/2014 09:12 AM, elson.wei@gmail.com wrote:
> # HG changeset patch
> # User Wei, Elson <elson.wei@gmail.com>
> # Date 1397113932 -28800
> #      Thu Apr 10 15:12:12 2014 +0800
> # Node ID 2fccd923044071bb78ae03aa5ddfbab358564514
> # Parent  dbf0fa39a5b81a226a8953e91c7d5a151d453e06
> hgweb: override the charset attribute in the http request
>
> The default http request character set is UTF-8. If the message is not encoded
> in UTF-8, such as big5, it cannot be shown correctly. The 'charset' is
> overridden by the root document's, such that the user can select the proper
> encoding in the browser.

Is this something everybody would want? In which cases will it change 
the default behaviour? In which cases will it force the user to select 
the proper encoding in the browser where it used to (perhaps 
accidentally) do the right thing?

/Mads

>
> diff --git a/mercurial/templates/static/mercurial.js b/mercurial/templates/static/mercurial.js
> --- a/mercurial/templates/static/mercurial.js
> +++ b/mercurial/templates/static/mercurial.js
> @@ -327,6 +327,7 @@
>       };
>   
>       xfr.open(method, url);
> +    xfr.overrideMimeType("text/xhtml; charset=" + document.characterSet.toLowerCase());
>       xfr.send();
>       onstart();
>       return xfr;
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
elson.wei@gmail.com - April 11, 2014, 10:35 a.m.
2014-04-10 20:13 GMT+08:00 Mads Kiilerich <mads@kiilerich.com>:

> On 04/10/2014 09:12 AM, elson.wei@gmail.com wrote:
>
>> # HG changeset patch
>> # User Wei, Elson <elson.wei@gmail.com>
>> # Date 1397113932 -28800
>> #      Thu Apr 10 15:12:12 2014 +0800
>> # Node ID 2fccd923044071bb78ae03aa5ddfbab358564514
>> # Parent  dbf0fa39a5b81a226a8953e91c7d5a151d453e06
>> hgweb: override the charset attribute in the http request
>>
>> The default http request character set is UTF-8. If the message is not
>> encoded
>> in UTF-8, such as big5, it cannot be shown correctly. The 'charset' is
>> overridden by the root document's, such that the user can select the
>> proper
>> encoding in the browser.
>>
>
> Is this something everybody would want? In which cases will it change the
> default behaviour? In which cases will it force the user to select the
> proper encoding in the browser where it used to (perhaps accidentally) do
> the right thing?
>

/Mads
>

If the commit message is written in the encoding other than UTF-8, the
ajax-loaded message will be shown incorrectly like other ajax applications.

I might modify the description as following:

    The default http request character set is UTF-8. If the message is not
encoded
    in UTF-8, such as big5, it cannot be shown correctly. The 'charset'
inherits
    from the root document, such that the browser or the user can determine
what
    the encoding should be used.


>
>
>> diff --git a/mercurial/templates/static/mercurial.js
>> b/mercurial/templates/static/mercurial.js
>> --- a/mercurial/templates/static/mercurial.js
>> +++ b/mercurial/templates/static/mercurial.js
>> @@ -327,6 +327,7 @@
>>       };
>>         xfr.open(method, url);
>> +    xfr.overrideMimeType("text/xhtml; charset=" + document.characterSet.
>> toLowerCase());
>>       xfr.send();
>>       onstart();
>>       return xfr;
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@selenic.com
>> http://selenic.com/mailman/listinfo/mercurial-devel
>>
>
>
Matt Mackall - April 11, 2014, 9:06 p.m.
On Thu, 2014-04-10 at 15:12 +0800, elson.wei@gmail.com wrote:
> # HG changeset patch
> # User Wei, Elson <elson.wei@gmail.com>
> # Date 1397113932 -28800
> #      Thu Apr 10 15:12:12 2014 +0800
> # Node ID 2fccd923044071bb78ae03aa5ddfbab358564514
> # Parent  dbf0fa39a5b81a226a8953e91c7d5a151d453e06
> hgweb: override the charset attribute in the http request

Looks sensible, queued for default, thanks.

Patch

diff --git a/mercurial/templates/static/mercurial.js b/mercurial/templates/static/mercurial.js
--- a/mercurial/templates/static/mercurial.js
+++ b/mercurial/templates/static/mercurial.js
@@ -327,6 +327,7 @@ 
     };
 
     xfr.open(method, url);
+    xfr.overrideMimeType("text/xhtml; charset=" + document.characterSet.toLowerCase());
     xfr.send();
     onstart();
     return xfr;