You are here: Foswiki>Tasks Web>Item13096 (05 Jul 2015, GeorgeClark)Edit Attach

Item13096: CommentPlugin generates "Invalid validation code" REST error when trying to add comment in Firefox

pencil
Priority: Urgent
Current State: Closed
Released In: 2.0.0
Target Release: major
Applies To: Extension
Component: CommentPlugin
Branches: master
Reported By: PascalSchuppli
Waiting For:
Last Change By: GeorgeClark

Problem Description

I have a page with a %COMMENT% macro. It works fine in Chrome, both on Linux and on Windows. When I try to add a comment in Firefox, upon hitting the "add comment" button, both on Linux (Firefox 30.0) and on Windows, Foswiki produces a validation code error. The log says:

| 2014-11-16T13:27:18Z warning | REST rejected: ERROR: (403) Invalid validation code |  CommentPlugin/comment - https://DELETED_FOR_PRIVACY_/Diskussionen |

Foswiki version: v1.2.0_999, Release Foswiki-1.2.0_999 svn, Plugin API version 2.3, with Foswiki Pseudo-Installed directly from github.

Possibly a manifestation of problems hinted at in Item10191 ?

-- PascalSchuppli - 16 Nov 2014


Any chance you are using a javascript blocker on firefox? The validation code is inserted through javascript.

-- GeorgeClark - 17 Nov 2014

Never mind. Confirmed on trunk.foswiki.org as well. Unable to comment on tasks here. Also tried Chromium, and it still fails for me.

-- GeorgeClark - 24 Nov 2014

Actually, Chromium works, as the original poster says, this is a firefox issue.

Running the Javascript debugger, I set a breakpoint in comment.js, in the following code:

                    StrikeOne.submit(form);
                $.ajax({
          url: form.action,
          type: "POST",
          data: $(form).serialize(),
                    beforeSend: function() {
                        $(form).find('input').attr("disabled", "disabled");
                    },
          success: function(data, textStatus, jqXHR) {
                        var position = jqXHR.getResponseHeader(
                            'X-Foswiki-Comment');
                        addComment(position, data, form);
                        $(form).find('input').removeAttr("disabled");
                        $("body").css("cursor", "default");
                    },
          error: function(jqXHR, textStatus, errorThrown) {  <<<<<<<<<BREAKPOINT
         alert("Error: " + errorThrown);
   

If I "Step OVER" from the error, everything appears to work just fine. there is no alert, the comment posts, and the page refreshes. Perfect. If I step into, (or don't set the breakpoint) the Alert is thrown, with the string Error: and no text following, so the alert happens with no error information.

I don't know where to go from her. Running Firefox 24.6.0

-- GeorgeClark - 02 Dec 2014

I observed something more:

When I try to post a comment in Firefox 30.0 (Linux), the alert box appears for a very short time and dissapears again. Then the error message ("invalid validation code") appears in the browser window. However, the comment IS added to the page.

When I look at the browser console, I see two POST requests to https://REMOVED_FOR_PRIVACY/bin/rest/CommentPlugin/comment; the first one succeeds, the second one fails with a "Forbidden" HTTP Status code. I assume this is because two ajax POSTs are done with the same validation token; the first one succeeds, the second one produces the error message.

-- PascalSchuppli - 02 Dec 2014

That's due to the race condition between the actual ajax call and the click event bubbling upwards resulting in the surrounding form being submitted in addition to the ajax call already in progress. I think Crawford's recent checkin cured this.

-- MichaelDaum - 03 Dec 2014
 

ItemTemplate edit

Summary CommentPlugin generates "Invalid validation code" REST error when trying to add comment in Firefox
ReportedBy PascalSchuppli
Codebase trunk
SVN Range
AppliesTo Extension
Component CommentPlugin
Priority Urgent
CurrentState Closed
WaitingFor
Checkins distro:7bca1b4aaa1d
TargetRelease major
ReleasedIn 2.0.0
CheckinsOnBranches master
trunkCheckins
masterCheckins distro:7bca1b4aaa1d
ItemBranchCheckins
Release01x01Checkins
Topic revision: r10 - 05 Jul 2015, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy