Modify

Opened 13 months ago

Closed 5 weeks 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 Changed 13 months ago by stoecker

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 13 months ago by stoecker (previous) (diff)

comment:2 Changed 13 months ago by Bjoeni

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 Changed 13 months ago by stoecker

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 Changed 13 months ago by Bjoeni

Ok, thanks.

comment:5 Changed 5 weeks ago by stoecker

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.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.