Skip to content

Commit

Permalink
Links in wiki search to add a missing page should encode the titles t…
Browse files Browse the repository at this point in the history
…o make them URL safe. Fixes bug #11883.
  • Loading branch information
perlDreamer committed Sep 27, 2010
1 parent dec9105 commit 0e8d5cf
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/changelog/7.x.x.txt
Expand Up @@ -7,6 +7,7 @@
- fixed: typo in the Gallery Add Archive default templateId.
- fixed #11876: packing templates, snippets, headtags removes conditional CSS comments
- fixed #11877: Criteria Builder on "shortcut by alternate criteria" gets ugly with many checkbox items
- fixed #11883: Wiki "Add page" link does not encode special chars

7.9.14
- fixed #11812: Checking www_ajaxSave's response in the cart js
Expand Down
3 changes: 2 additions & 1 deletion lib/WebGUI/Asset/Wobject/WikiMaster.pm
Expand Up @@ -23,6 +23,7 @@ use WebGUI::Utility;
use HTML::Parser;
use URI::Escape;
use WebGUI::Form;
use WebGUI::Search;
use Clone qw/clone/;

#-------------------------------------------------------------------
Expand Down Expand Up @@ -985,7 +986,7 @@ sub www_search {
mostPopularUrl=>$self->getUrl("func=mostPopular"),
mostPopularLabel=>$i18n->get("mostPopularLabel"),
wikiHomeUrl=>$self->getUrl,
addPageUrl=>$self->getUrl("func=add;class=WebGUI::Asset::WikiPage;title=".$queryString),
addPageUrl=>$self->getUrl("func=add;class=WebGUI::Asset::WikiPage;title=".$self->session->url->escape($queryString)),
};
$self->appendSearchBoxVars($var, $queryString);
if (length $queryString) {
Expand Down
67 changes: 67 additions & 0 deletions t/Asset/Wobject/WikiMaster/search.t
@@ -0,0 +1,67 @@
# vim:syntax=perl
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------

# Test the featured page of the Wiki
#
#

use FindBin;
use strict;
use lib "$FindBin::Bin/../../../lib";
use Test::More;
use Test::Deep;
use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Session;

#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
my $import = WebGUI::Asset->getImportNode( $session );

my $templateId = 'WIKIMASTER_TEMPLATE___';

my $templateMock = Test::MockObject->new({});
$templateMock->set_isa('WebGUI::Asset::Template');
$templateMock->set_always('getId', $templateId);
my $templateVars;
$templateMock->mock('process', sub { $templateVars = $_[1]; } );

my $wiki
= $import->addChild( {
className => 'WebGUI::Asset::Wobject::WikiMaster',
searchTemplateId => $templateId,
} );

WebGUI::Test->addToCleanup($wiki);

#----------------------------------------------------------------------------
# Tests

plan tests => 1; # Increment this number for each test you create

$session->request->setup_body({
query => 'Red&Andy',
});

{
WebGUI::Test->mockAssetId($templateId, $templateMock);
$wiki->www_search();
WebGUI::Test->unmockAssetId($templateId);
}

is $templateVars->{addPageUrl},
$wiki->getUrl('func=add;class=WebGUI::Asset::WikiPage;title=Red%26Andy'),
'search encodes unsafe characters in addPageUrl';

#----------------------------------------------------------------------------
#

#vim:ft=perl

0 comments on commit 0e8d5cf

Please sign in to comment.