Skip to content

Commit

Permalink
Item13199: there was indeed a JS error, but it was caused by the chan…
Browse files Browse the repository at this point in the history
…ges I made to suport %NONCE%. Fixed (and also eliminated a dangerous JS eval)
  • Loading branch information
Comment committed Jan 12, 2015
1 parent 7c49f6e commit 7b81775
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions FamFamFamContrib/templates/view.famfamfam.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
</a></span>%TMPL:END%

%TMPL:DEF{"top:toolbarbutton_subscribe"}%<span>
%SUBSCRIBE{format="<a href='$url' class='subscribe_link' data-subscribe='$restparams' rel='nofollow' title='%MAKETEXT{"Subscribe to this topic (s)"}%'>
%SUBSCRIBE{format="<a href='$url' class='subscribe_link' data-subscribe='{validation_key:"%NONCE%"}' rel='nofollow' title='%MAKETEXT{"Subscribe to this topic (s)"}%'>
<img alt='%MAKETEXT{"Subscribe to this topic (s)"}%' src='%PUBURL%/%SYSTEMWEB%/DocumentGraphics/notify.png' width='16' height='16' />
</a>" formatunsubscribe="<a href='$url' class='subscribe_link' data-subscribe='$restparams' rel='nofollow' title='%MAKETEXT{"Unsubscribe from this topic (s)"}%'>
</a>" formatunsubscribe="<a href='$url' class='subscribe_link' data-subscribe='{validation_key:"%NONCE%"}' rel='nofollow' title='%MAKETEXT{"Unsubscribe from this topic (s)"}%'>
<img alt='%MAKETEXT{"Unsubscribe from this topic (s)"}%' src='%PUBURL%/%SYSTEMWEB%/DocumentGraphics/notify.png' width='16' height='16' />
</a>"}%</span>%TMPL:END%

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
$('.subscribe_link').each(function() {
var clink = $(this);
var params = clink.data('subscribe');
clink.data('subscribe', eval(params));
clink.data('subscribe', params);
});
});
})(jQuery);
4 changes: 2 additions & 2 deletions SubscribePlugin/templates/subscribe.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
Link for a "subscribe" request. Note that REST parameters are encoded in
data-subscribe
}%%TMPL:DEF{sp:subscribe}%
<a class="subscribe_link" data-subscribe="$restparams" rel="nofollow" title="%MAKETEXT{"Subscribe to this topic"}%" href="$url">%MAKETEXT{"Subscribe"}%</a>
<a class="subscribe_link" data-subscribe="{validation_key:'%NONCE%'}" rel="nofollow" title="%MAKETEXT{"Subscribe to this topic"}%" href="$url">%MAKETEXT{"Subscribe"}%</a>
%TMPL:END%
%{----------------------------------------
Link for an "unsubscribe" request. Note that REST parameters are encoded in
data-subscribe
}%%TMPL:DEF{sp:unsubscribe}%
<a class="subscribe_link" data-subscribe="$restparams" rel="nofollow" title="%MAKETEXT{"Unsubscribe from this topic"}%" href="$url">%MAKETEXT{"Unsubscribe"}%</a>
<a class="subscribe_link" data-subscribe="{validation_key:'%NONCE%'}" rel="nofollow" title="%MAKETEXT{"Unsubscribe from this topic"}%" href="$url">%MAKETEXT{"Unsubscribe"}%</a>
%TMPL:END%
%{----------------------------------------
Error message
Expand Down
7 changes: 5 additions & 2 deletions core/lib/Foswiki/Macros/NONCE.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ sub NONCE {
my $context =
$this->{request}->url( -full => 1, -path => 1, -query => 1 ) . time();
my $cgis = $this->{users}->getCGISession();
return '' unless $cgis;
return Foswiki::Validation::generateValidationKey( $cgis, $context, 1 );
my $nonce =
$cgis
? Foswiki::Validation::generateValidationKey( $cgis, $context, 1 )
: '';
return $nonce;
}

1;
Expand Down
3 changes: 2 additions & 1 deletion core/lib/Foswiki/Validation.pm
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ Generate a new validation key. The key will time out after
page plus the time. This should be unique for each rendered page.
* =$strikeone= - if set, expect the nonce to be combined with the
session secret before it is posted back.
The validation key wcan then be used in a HTML form, or headers for RestPlugin API etc.
The validation key can then be used in a HTML form, or headers for
RestPlugin API etc.
=cut

Expand Down
2 changes: 1 addition & 1 deletion core/templates/viewtopicactionbuttons.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

%TMPL:DEF{"attach_link"}%<span class="foswikiRequiresChangePermission"><a href='%SCRIPTURLPATH{"attach"}%/%BASEWEB%/%BASETOPIC%' rel='nofollow' %IF{"context footer_text" then="%MAKETEXT{"title='Attach an image or document to this topic' accesskey='a'>&Attach"}%" else="%MAKETEXT{"title='Attach an image or document to this topic'>Attach"}%" }%</a></span>%TMPL:END%

%TMPL:DEF{"subscribe_link"}%<span>%SUBSCRIBE{format="<a href='$url' class='subscribe_link' data-subscribe='$restparams' rel='nofollow' %MAKETEXT{"title='Subscribe to this topic' accesskey='s'>&Subscribe"}%</a>" formatunsubscribe="<a href='$url' class='subscribe_link' data-subscribe='$restparams' rel='nofollow' %MAKETEXT{"title='Unsubscribe from this topic' accesskey='s'>Un&subscribe"}%</a>"}%</span>%TMPL:END%
%TMPL:DEF{"subscribe_link"}%<span>%SUBSCRIBE{format="<a href='$url' class='subscribe_link' data-subscribe='{\"validation_key\":\"%NONCE%\"}' rel='nofollow' %MAKETEXT{"title='Subscribe to this topic' accesskey='s'>&Subscribe"}%</a>" formatunsubscribe="<a href='$url' class='subscribe_link' data-subscribe='$restparams' rel='nofollow' %MAKETEXT{"title='Unsubscribe from this topic' accesskey='s'>Un&subscribe"}%</a>"}%</span>%TMPL:END%

%TMPL:DEF{"more_link"}%<span><a href='%SCRIPTURLPATH{"view"}%/%BASEWEB%/%BASETOPIC%?template=more&maxrev=%MAXREV%&currrev=%CURRREV%' rel='nofollow' %MAKETEXT{"title='Delete or rename this topic; set parent topic; view and compare revisions' accesskey='m'>&More topic actions"}%</a></span>%TMPL:END%

Expand Down

0 comments on commit 7b81775

Please sign in to comment.