Modify

Opened 4 years ago

Closed 3 years ago

#20983 closed defect (fixed)

Spam report not working on second attempt

Reported by: Bjoeni Owned by: stoecker
Priority: normal Milestone:
Component: Trac Version:
Keywords: Cc:

Description

When reporting a ticket using the "report spam" function, a prompt asks for a comment.

If that is cancelled, the this.href (of the link) is set to the document URL (I assume to prevent the spam report from being sent).
When that URL contains a # (e.g. anchor from a comment) the page will not be reloaded, which means the second time (when a valid comment is provided) the href is still set to the ticket URL and the report will never be sent.

See https://josm.openstreetmap.de/chrome/spamfilter/reportspam.js: event.preventDefault() should be used instead of changing the href.

Also some kind of feedback that the report was successfully sent would be nice instead of just redirecting back to the ticket.

Attachments (0)

Change History (5)

comment:1 by stoecker, 4 years ago

As you already analyzed the issue, can you provide a patch? Also for the feedback (user visible text must go via the html page as variable, as no translation is possible in the js directly).

https://trac.edgewall.org/wiki/SpamFilter#GetthePlugin

Last edited 4 years ago by stoecker (previous) (diff)

comment:2 by Bjoeni, 4 years ago

Well this should do the job for the reportspam.js:

jQuery(function($){
    $("#reportspam").click(function(event){
      var comment = prompt(spamreport_comment, "");
      if (comment == null) {
          event.preventDefault();
          return;
      }
      this.href += "&comment=" + encodeURIComponent(comment);
    });
});

But I only analyzed it on the client side. I have absolutely no clue regarding trac plugin development or python in general, I didn't even know it was a plugin until now. I assume the magic should happen somewhere around report.py#L58, but I don't know how to display a message there.

comment:3 by stoecker, 4 years ago

Ah. Right. I thought about a JS alert(), but your' right. I simply can issue an add_notice(). I'll do so when I find a bit time for this.

comment:4 by Bjoeni, 4 years ago

Ok, thanks.

comment:5 by stoecker, 3 years ago

Resolution: fixed
Status: newclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain stoecker.
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.