Changeset 6350 in josm for trunk/src


Ignore:
Timestamp:
2013-11-01T21:32:02+01:00 (11 years ago)
Author:
Don-vip
Message:

fix #9201 - Remote control: Additional validation of arguments of load_and_zoom handler

File:
1 edited

Legend:

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

    r6332 r6350  
    3030
    3131/**
    32  * Handler for load_and_zoom request.
     32 * Handler for {@code load_and_zoom} and {@code zoom} requests.
     33 * @since 3707
    3334 */
    34 public class LoadAndZoomHandler extends RequestHandler
    35 {
     35public class LoadAndZoomHandler extends RequestHandler {
     36   
    3637    /**
    3738     * The remote control command name used to load data and zoom.
     
    5657
    5758    @Override
    58     public String getPermissionMessage()
    59     {
     59    public String getPermissionMessage() {
    6060        String msg = tr("Remote Control has been asked to load data from the API.") +
    6161                "<br>" + tr("Bounding box: ") + new BBox(minlon, minlat, maxlon, maxlat).toStringCSV(", ");
     
    6767
    6868    @Override
    69     public String[] getMandatoryParams()
    70     {
     69    public String[] getMandatoryParams() {
    7170        return new String[] { "bottom", "top", "left", "right" };
    7271    }
    7372
    7473    @Override
    75     public String[] getOptionalParams()
    76     {
     74    public String[] getOptionalParams() {
    7775        return new String[] {"new_layer", "addtags", "select", "zoom_mode"};
    7876    }
     
    9694
    9795    @Override
    98     protected void handleRequest() throws RequestHandlerErrorException
    99     {
     96    protected void handleRequest() throws RequestHandlerErrorException {
    10097        DownloadTask osmTask = new DownloadOsmTask();
    10198        try {
     
    241238        } catch (NumberFormatException e) {
    242239            throw new RequestHandlerBadRequestException("NumberFormatException ("+e.getMessage()+")");
     240        }
     241       
     242        // Current API 0.6 check: "The latitudes must be between -90 and 90"
     243        if (!LatLon.isValidLat(minlat) || !LatLon.isValidLat(maxlat)) {
     244            throw new RequestHandlerBadRequestException(tr("The latitudes must be between {0} and {1}", -90d, 90d));
     245        }
     246        // Current API 0.6 check: "longitudes between -180 and 180"
     247        if (!LatLon.isValidLon(minlon) || !LatLon.isValidLon(maxlon)) {
     248            throw new RequestHandlerBadRequestException(tr("The longitudes must be between {0} and {1}", -180d, 180d));
     249        }
     250        // Current API 0.6 check: "the minima must be less than the maxima"
     251        if (minlat > maxlat || minlon > maxlon) {
     252            throw new RequestHandlerBadRequestException(tr("The minima must be less than the maxima"));
    243253        }
    244254
Note: See TracChangeset for help on using the changeset viewer.