Modify

Opened 3 years ago

Closed 3 years ago

#13187 closed defect (fixed)

[PATCH] Set encoding of remote control error pages to UTF-8 and HTML-escape the localized messages

Reported by: floscher Owned by: floscher
Priority: normal Milestone: 16.07
Component: Core remotecontrol Version: latest
Keywords: encoding html Cc:

Description

Currently the error pages of the remote control are delivered to the browser without information about the encoding (neither via HTTP-header nor via <meta>-tag in the HTML), while in fact the pages are encoded with UTF-8. So these pages are displayed incorrectly when the user has not set UTF-8 as default encoding in his/her browser and the page contains special characters like Umlauts.

An example is http://127.0.0.1:8111/load_and_zoom?right=0&top=0&left=1&bottom=1 when you set the display language of JOSM to German. Then the page reads Die Minima müssen geringer als die Maxima sein.

This patch both adds the encoding to the HTTP-header and adds <meta charset="utf8"> to the HTML of the error pages. Additionally it also adds HTML-escaping to the localized messages, so they could even contain <, > or & and still be displayed correctly.

The patch has been created against version 10583 and is attached to this ticket, or can be viewed at
https://github.com/floscher/josm/commit/776bb6d8b1a0e35492151835f7ac612ede1f8596 (Raw patch, Raw diff)

Attachments (2)

776bb6d8b1a0e35492151835f7ac612ede1f8596.patch (6.8 KB) - added by floscher 3 years ago.
59c2a1c268fc1f309258b75729b5bd450331ec22.patch (7.3 KB) - added by floscher 3 years ago.

Download all attachments as: .zip

Change History (8)

Changed 3 years ago by floscher

comment:1 Changed 3 years ago by stoecker

Two points:

  • I'm not sure if omitting head, html and body is really a good idea even if HTML5 allows it. These few characters don't cost much, but it can be expected that not everybody correctly deals with omitting them.
  • The tr() change would be correct like this:
    tr("The following keys are mandatory, but have not been provided: {0}",
    Utils.join(", ", missingKeys)));
    

comment:2 Changed 3 years ago by Don-vip

Milestone: 16.07

comment:3 Changed 3 years ago by Don-vip

Component: CoreCore remotecontrol
Keywords: encoding html added; remotecontrol removed

comment:4 Changed 3 years ago by Don-vip

Status: newneedinfo

Looks good, thanks for the patch :) Can you please update it by taking into account Dirk's remarks, then I'll commit it?

Changed 3 years ago by floscher

comment:5 Changed 3 years ago by floscher

Thank you for the review. I attached the improved patch taking both suggestions into account.

comment:6 Changed 3 years ago by Don-vip

Resolution: fixed
Status: needinfoclosed

In 10587/josm:

fix #13187 - Set encoding of remote control error pages to UTF-8 and HTML-escape the localized messages (patch by floscher)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain floscher.
as The resolution will be set.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.