Links in wiki search to add a missing page should encode the titles to make them URL safe. Fixes bug #11883.

This commit is contained in:
Colin Kuskie 2010-09-27 09:29:07 -07:00
parent c3d0c74952
commit 0406e82546
3 changed files with 70 additions and 1 deletions

View file

@ -1,6 +1,7 @@
7.10.2
- fixed #11884: Editing Templates impossible / Code editor not loaded
- recommitted ukplayer. Removal broke Matrix. Licencing information was available but overlooked.
- fixed #11883: Wiki "Add page" link does not encode special chars
7.10.1
- fixed #11851: Story Topic: top story variables should be available all the time

View file

@ -23,6 +23,7 @@ use WebGUI::Utility;
use HTML::Parser;
use URI::Escape;
use WebGUI::Form;
use WebGUI::Search;
use Clone qw/clone/;
#-------------------------------------------------------------------
@ -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) {

View file

@ -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