Modify

Opened 3 years ago

Closed 2 years ago

#20823 closed enhancement (fixed)

[patch] Reject uploads that do not follow either comment policy or source policy

Reported by: ljdelight Owned by: team
Priority: normal Milestone: 22.06
Component: Core Version:
Keywords: upload comment source policy terms Cc:

Description

The upload checks on the comment/source policy needs a slight tweak since an invalid 'comment' and valid 'source' are allowed to be uploaded (either case being invalid should stop an upload).

This patch checks that both (the comment and source) comments are valid before allowing an upload.

Attachments (3)

patch-20823.patch (5.1 KB ) - added by ljdelight 3 years ago.
patch-20823-2.patch (6.1 KB ) - added by ljdelight 3 years ago.
Fixed
patch-20823-3.patch (9.1 KB ) - added by ljdelight 2 years ago.
Rebased to trunk and added unit test for this case

Download all attachments as: .zip

Change History (16)

by ljdelight, 3 years ago

Attachment: patch-20823.patch added

comment:1 by simon04, 3 years ago

Milestone: 21.05

comment:2 by simon04, 3 years ago

Owner: changed from team to ljdelight
Status: newneedinfo

Sorry, I don't see how this patch makes a difference. Since UploadCommentValidator/UploadSourceValidator both extend UploadTextComponentValidator, they never share the boolean uploadRejected field.

Please add a unit test to org.openstreetmap.josm.gui.io.UploadTextComponentValidatorTest showing where your patch makes a difference.

comment:3 by simon04, 3 years ago

Resolution: needinfo
Status: needinfoclosed

comment:4 by simon04, 3 years ago

Milestone: 21.05

comment:5 by ljdelight, 3 years ago

Slow reply, sorry about that, @simon04 can we re-open this ticket? I'll make a new patch and digging in to why the UploadTextComponentValidator.isUploadRejected is returning false in a specific case

by ljdelight, 3 years ago

Attachment: patch-20823-2.patch added

Fixed

comment:6 by ljdelight, 3 years ago

My initial patch makes no sense, you're absolutely right @simon04 and I feel silly :-)

The latest patch fixes the issue.
There were two problems causing the upload button to be selectable even though the comment/source tag policy was not met:

  • The input length was validated first and took priority over the tag policy. This is resolved by checking the tag policy and, if that's valid, then we check the input length.
  • The upload button state is modified by callbacks which check the tag policy, however the initial state of the button doesn't account for the tag policy.

To reproduce the issue:

  1. In the advanced settings set a comment or source tag policy (eg upload.comment.mandatory-terms)
  2. Download a small map area and make a minor change to a map (eg move a node)
  3. Click the Upload button
  4. The Upload Changes button is selectable. This should not be the case.
  5. Type at least 11 characters to trigger the update events of the dialog which check the tag policy
  6. The Upload Changes button is now not selectable

comment:7 by ljdelight, 3 years ago

Resolution: needinfo
Status: closedreopened

comment:8 by ljdelight, 3 years ago

Hi @simon04, any updates you need from me here? Thanks

comment:9 by ljdelight, 3 years ago

Owner: changed from ljdelight to team
Status: reopenednew

Reassigning owner from me to 'team', that seems to match other tickets

comment:10 by taylor.smock, 2 years ago

The functionality seems to work. Would you mind (if you are still around) writing tests, as simon04 said in comment:2. That way we will notice if it is accidentally broken.

by ljdelight, 2 years ago

Attachment: patch-20823-3.patch added

Rebased to trunk and added unit test for this case

comment:11 by ljdelight, 2 years ago

Hi Taylor, I added patch-20823-3.patch and it contains changes that work against trunk and includes unit tests.

comment:12 by taylor.smock, 2 years ago

Milestone: 22.06

It looks good to me. I'll go ahead and merge this on Monday to give other maintainers a chance to look at it.

If I forget to merge this on Monday (UTC-6), feel free to ping me.

Anyway, I'm sorry that your patch has been forgotten for ~1 year. I've been trying to go through tickets with patches attached (see report:8), but I've been mostly focused on (a) new tickets and (b) recent patches.

comment:13 by taylor.smock, 2 years ago

Resolution: fixed
Status: newclosed

In 18491/josm:

Fix #20823: Reject uploads that do not follow either comment policy or source policy (patch by ljdelight)

This fixes an issue where a the length of the comment or source was checked first,
and a warning instead of a rejection was generated when the upload policy would
have otherwise rejected the comment or source.

This also performs the validation check first, prior to the user being able to
make changes in the upload dialog UI, so that the initial dialog state matches
the upload policy.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.