Ignore:
Timestamp:
2012-03-18T18:38:34+01:00 (12 years ago)
Author:
simon04
Message:

fix #5824 - remote control: decode URL

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/RequestHandler.java

    r5085 r5103  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.io.UnsupportedEncodingException;
     7import java.net.URLDecoder;
    68import java.text.MessageFormat;
    79import java.util.HashMap;
     
    142144    /**
    143145     * Parse the request parameters as key=value pairs.
    144      * The result will be stored in this.args.
     146     * The result will be stored in {@code this.args}.
    145147     *
    146148     * Can be overridden by subclass.
    147149     */
    148150    protected void parseArgs() {
    149         HashMap<String, String> args = new HashMap<String, String>();
    150         if (this.request.indexOf('?') != -1) {
    151             String query = this.request.substring(this.request.indexOf('?') + 1);
    152             if (query.indexOf('#') != -1) {
    153                 query = query.substring(0, query.indexOf('#'));
    154             }
    155             String[] params = query.split("&", -1);
    156             for (String param : params) {
    157                 int eq = param.indexOf('=');
    158                 if (eq != -1) {
    159                     args.put(param.substring(0, eq), param.substring(eq + 1));
     151        try {
     152            String req = URLDecoder.decode(this.request, "UTF-8");
     153            HashMap<String, String> args = new HashMap<String, String>();
     154            if (req.indexOf('?') != -1) {
     155                String query = req.substring(req.indexOf('?') + 1);
     156                if (query.indexOf('#') != -1) {
     157                    query = query.substring(0, query.indexOf('#'));
    160158                }
    161             }
    162         }
    163         this.args = args;
     159                String[] params = query.split("&", -1);
     160                for (String param : params) {
     161                    int eq = param.indexOf('=');
     162                    if (eq != -1) {
     163                        args.put(param.substring(0, eq), param.substring(eq + 1));
     164                    }
     165                }
     166            }
     167            this.args = args;
     168        } catch (UnsupportedEncodingException ex) {
     169            throw new IllegalStateException(ex);
     170        }
    164171    }
    165172
Note: See TracChangeset for help on using the changeset viewer.