Changeset 7995 in josm for trunk/src


Ignore:
Timestamp:
2015-01-31T15:17:59+01:00 (10 years ago)
Author:
Don-vip
Message:

fix #11047 - changeset: no length check for the source field

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/Changeset.java

    r7715 r7995  
    1313import org.openstreetmap.josm.data.coor.LatLon;
    1414import org.openstreetmap.josm.data.osm.visitor.Visitor;
     15import org.openstreetmap.josm.tools.CheckParameterUtil;
    1516
    1617/**
     
    2122public final class Changeset implements Tagged {
    2223
    23     /** The maximum changeset comment text length allowed by API 0.6 **/
    24     public static final int MAX_COMMENT_LENGTH = 255;
     24    /** The maximum changeset tag length allowed by API 0.6 **/
     25    public static final int MAX_CHANGESET_TAG_LENGTH = 255;
    2526
    2627    /** the changeset id */
     
    191192    @Override
    192193    public void setKeys(Map<String, String> keys) {
     194        CheckParameterUtil.ensureParameterNotNull(keys, "keys");
     195        for (String value : keys.values()) {
     196            if (value != null && value.length() > MAX_CHANGESET_TAG_LENGTH) {
     197                throw new IllegalArgumentException("Changeset tag value is too long: "+value);
     198            }
     199        }
    193200        this.tags = keys;
    194201    }
     
    204211    @Override
    205212    public void put(String key, String value) {
     213        CheckParameterUtil.ensureParameterNotNull(key, "key");
     214        if (value != null && value.length() > MAX_CHANGESET_TAG_LENGTH) {
     215            throw new IllegalArgumentException("Changeset tag value is too long: "+value);
     216        }
    206217        this.tags.put(key, value);
    207218    }
  • trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java

    r7039 r7995  
    3434
    3535/**
    36  * BasicUploadSettingsPanel allows to enter the basic parameters required for uploading
    37  * data.
    38  *
     36 * BasicUploadSettingsPanel allows to enter the basic parameters required for uploading data.
     37 * @since 2599
    3938 */
    4039public class BasicUploadSettingsPanel extends JPanel {
     
    5655        JPanel pnl = new JPanel(new GridBagLayout());
    5756
    58         final JEditorPane commentLabel = new JMultilineLabel("<html><b>" + tr("Provide a brief comment for the changes you are uploading:"));
     57        JEditorPane commentLabel = new JMultilineLabel("<html><b>" + tr("Provide a brief comment for the changes you are uploading:"));
    5958        pnl.add(commentLabel, GBC.eol().insets(0, 5, 10, 3).fill(GBC.HORIZONTAL));
    6059        hcbUploadComment.setToolTipText(tr("Enter an upload comment"));
    61         hcbUploadComment.setMaxTextLength(Changeset.MAX_COMMENT_LENGTH);
     60        hcbUploadComment.setMaxTextLength(Changeset.MAX_CHANGESET_TAG_LENGTH);
    6261        List<String> cmtHistory = new LinkedList<>(Main.pref.getCollection(HISTORY_KEY, new LinkedList<String>()));
    6362        Collections.reverse(cmtHistory); // we have to reverse the history, because ComboBoxHistory will reverse it again in addElement()
    6463        hcbUploadComment.setPossibleItems(cmtHistory);
    65         final CommentModelListener commentModelListener = new CommentModelListener(hcbUploadComment, changesetCommentModel);
     64        CommentModelListener commentModelListener = new CommentModelListener(hcbUploadComment, changesetCommentModel);
    6665        hcbUploadComment.getEditor().addActionListener(commentModelListener);
    6766        hcbUploadComment.getEditor().getEditorComponent().addFocusListener(commentModelListener);
    6867        pnl.add(hcbUploadComment, GBC.eol().fill(GBC.HORIZONTAL));
    6968
    70         final JEditorPane sourceLabel = new JMultilineLabel("<html><b>" + tr("Specify the data source for the changes")
     69        JEditorPane sourceLabel = new JMultilineLabel("<html><b>" + tr("Specify the data source for the changes")
    7170                + "</b> (<a href=\"urn:changeset-source\">" + tr("obtain from current layers") + "</a>)<b>:</b>");
    7271        sourceLabel.addHyperlinkListener(new HyperlinkListener() {
     
    8382
    8483        hcbUploadSource.setToolTipText(tr("Enter a source"));
    85         List<String> sourceHistory = new LinkedList<>(Main.pref.getCollection(SOURCE_HISTORY_KEY, Arrays.asList("knowledge", "survey", "Bing")));
     84        hcbUploadSource.setMaxTextLength(Changeset.MAX_CHANGESET_TAG_LENGTH);
     85        List<String> sourceHistory = new LinkedList<>(Main.pref.getCollection(SOURCE_HISTORY_KEY,
     86                Arrays.asList("knowledge", "survey", "Bing")));
    8687        Collections.reverse(sourceHistory); // we have to reverse the history, because ComboBoxHistory will reverse it again in addElement()
    8788        hcbUploadSource.setPossibleItems(sourceHistory);
    88         final CommentModelListener sourceModelListener = new CommentModelListener(hcbUploadSource, changesetSourceModel);
     89        CommentModelListener sourceModelListener = new CommentModelListener(hcbUploadSource, changesetSourceModel);
    8990        hcbUploadSource.getEditor().addActionListener(sourceModelListener);
    9091        hcbUploadSource.getEditor().getEditorComponent().addFocusListener(sourceModelListener);
Note: See TracChangeset for help on using the changeset viewer.