forward porting fix for non-unique separator strings, ~~~, #8543

This commit is contained in:
Colin Kuskie 2008-11-21 23:07:05 +00:00
parent 9eff3a4b77
commit 13eb87ffe5
13 changed files with 54 additions and 27 deletions

View file

@ -46,6 +46,7 @@
- fixed #9132: usage error in Hover Help
- fixed #4181: hoover help for 'encrypt login' is wrong
- fixed #4186: search results (macro not expanded in the synopsis field)
- fixed #4191: Using 3 consecutive tildes in a Post title makes a bad URL/Pos
7.6.3
- improved performance of file uploads

View file

@ -1244,6 +1244,23 @@ sub getRoot {
}
#-------------------------------------------------------------------
=head2 getSeparator
Returns a very unique string that can be used for splitting head and body apart
from the style template. Made into a method in case it ever has to be changed
again.
=cut
sub getSeparator {
my $self = shift;
my $padCharacter = shift || '~';
my $pad = $padCharacter x 3;
return $pad.$self->getId.$pad
}
#-------------------------------------------------------------------
=head2 getTempspace ( session )

View file

@ -2422,8 +2422,8 @@ ENDJS
### Show the processed template
$session->http->sendHeader;
my $style = $session->style->process("~~~",$self->getParent->get("styleTemplateId"));
my ($head, $foot) = split("~~~",$style);
my $style = $session->style->process($self->getSeparator,$self->getParent->get("styleTemplateId"));
my ($head, $foot) = split($self->getSeparator,$style);
$self->session->output->print($head, 1);
$self->session->output->print($self->processTemplate($var, undef, $template));
$self->session->output->print($foot, 1);
@ -2460,8 +2460,8 @@ sub www_view {
$self->session->http->setCacheControl($self->get("visitorCacheTimeout")) if ($self->session->user->isVisitor);
$self->session->http->sendHeader;
$self->prepareView;
my $style = $self->getParent->processStyle("~~~");
my ($head, $foot) = split("~~~",$style);
my $style = $self->getParent->processStyle($self->getSeparator);
my ($head, $foot) = split($self->getSeparator,$style);
$self->session->output->print($head,1);
$self->session->output->print($self->view);
$self->session->output->print($foot,1);

View file

@ -1070,8 +1070,8 @@ sub www_view {
$self->session->http->setLastModified($self->getContentLastModified);
$self->session->http->sendHeader;
$self->prepareView;
my $style = $self->processStyle("~~~");
my ($head, $foot) = split("~~~",$style);
my $style = $self->processStyle($self->getSeparator);
my ($head, $foot) = split($self->getSeparator,$style);
$self->session->output->print($head, 1);
$self->session->output->print($self->view);
$self->session->output->print($foot, 1);

View file

@ -1175,8 +1175,8 @@ sub www_view {
$self->session->http->setCacheControl($self->get("visitorCacheTimeout")) if ($self->session->user->isVisitor);
$self->session->http->sendHeader;
$self->prepareView;
my $style = $self->getParent->processStyle("~~~");
my ($head, $foot) = split("~~~",$style);
my $style = $self->getParent->processStyle($self->getSeparator);
my ($head, $foot) = split($self->getSeparator,$style);
$self->session->output->print($head,1);
$self->session->output->print($self->view($currentPost));
$self->session->output->print($foot,1);

View file

@ -973,8 +973,8 @@ sub www_view {
if ($shortcut->isa('WebGUI::Asset::Wobject')) {
$self->session->http->setLastModified($self->getContentLastModified);
$self->session->http->sendHeader;
my $style = $shortcut->processStyle("~~~");
my ($head, $foot) = split("~~~",$style);
my $style = $shortcut->processStyle($self->getSeparator);
my ($head, $foot) = split($self->getSeparator,$style);
$self->session->output->print($head, 1);
$self->session->output->print($self->view);
$self->session->output->print($foot, 1);

View file

@ -514,8 +514,8 @@ sub www_view {
$self->session->http->setLastModified($self->getContentLastModified);
$self->session->http->sendHeader;
$self->prepareView;
my $style = $self->processStyle("~~~");
my ($head, $foot) = split("~~~",$style);
my $style = $self->processStyle($self->getSeparator);
my ($head, $foot) = split($self->getSeparator,$style);
$self->session->output->print($head, 1);
$self->session->output->print($self->view);
$self->session->output->print($foot, 1);

View file

@ -548,8 +548,8 @@ sub www_view {
});
}
$self->prepareView;
my $style = $self->processStyle("~~~");
my ($head, $foot) = split("~~~",$style);
my $style = $self->processStyle($self->getSeparator);
my ($head, $foot) = split($self->getSeparator,$style);
$self->session->output->print($head, 1);
$self->session->output->print($self->view);
$self->session->output->print($foot, 1);

View file

@ -2087,8 +2087,8 @@ sub www_search {
# This is very bad! It should be $self->processStyle or whatnot.
$self->session->http->sendHeader;
my $template = WebGUI::Asset::Template->new($self->session,$self->get("templateIdSearch"));
my $style = $self->session->style->process("~~~",$self->get("styleTemplateId"));
my ($head, $foot) = split("~~~",$style);
my $style = $self->session->style->process($self->getSeparator,$self->get("styleTemplateId"));
my ($head, $foot) = split($self->getSeparator,$style);
$self->session->output->print($head, 1);
$self->session->output->print($self->processTemplate($var, undef, $template));
$self->session->output->print($foot, 1);

View file

@ -763,8 +763,8 @@ sub sendChunkedContent {
$self->session->http->setLastModified($self->getContentLastModified);
$self->session->http->sendHeader;
my $style = $self->processStyle("~~~");
my ($head, $foot) = split("~~~",$style);
my $style = $self->processStyle($self->getSeparator);
my ($head, $foot) = split($self->getSeparator,$style);
$self->session->output->print($head, 1);
$self->session->output->print( $callback->() );
$self->session->output->print($foot, 1);

View file

@ -439,8 +439,8 @@ sub www_view {
return $output;
} else {
$self->session->http->sendHeader;
my $style = $self->processStyle("~~~");
my ($head, $foot) = split("~~~",$style);
my $style = $self->processStyle($self->getSeparator);
my ($head, $foot) = split($self->getSeparator,$style);
$self->session->output->print($head);
$self->session->output->print($output, 1); # Do not process macros
$self->session->output->print($foot);

View file

@ -196,14 +196,14 @@ sub prepareView {
push(@{$vars{"position1_loop"}},{
id=>$child->getId,
isUncommitted=> $child->get('status') eq 'pending',
content=>"~~~".$child->getId."~~~~~"
content=>$self->getSeparator.$child->getId.$self->getSeparator('!'),
});
} else {
$placeHolder{$child->getId} = $child;
push(@{$vars{"position".$i."_loop"}},{
id=>$child->getId,
isUncommitted=>$child->get('status') eq 'pending',
content=>"~~~".$child->getId."~~~~~"
content=>$self->getSeparator.$child->getId.$self->getSeparator('!'),
});
}
}
@ -226,13 +226,13 @@ sub prepareView {
if($self->getValue("assetOrder") eq "asc"){
push(@{$vars{"position1_loop"}},{
id=>$child->getId,
content=>"~~~".$child->getId."~~~~~"
content=>$self->getSeparator.$child->getId.$self->getSeparator('!'),
});
}
else {
unshift(@{$vars{"position1_loop"}},{
id=>$child->getId,
content=>"~~~".$child->getId."~~~~~"
content=>$self->getSeparator.$child->getId.$self->getSeparator('!'),
});
}
}
@ -272,10 +272,10 @@ sub view {
}
my $showPerformance = $self->session->errorHandler->canShowPerformanceIndicators();
my $out = $self->processTemplate($self->{_viewVars},undef,$self->{_viewTemplate});
my @parts = split("~~~~~",$self->processTemplate($self->{_viewVars},undef,$self->{_viewTemplate}));
my @parts = split($self->getSeparator('!'),$self->processTemplate($self->{_viewVars},undef,$self->{_viewTemplate}));
my $output = "";
foreach my $part (@parts) {
my ($outputPart, $assetId) = split("~~~",$part,2);
my ($outputPart, $assetId) = split($self->getSeparator,$part,2);
if ($self->{_viewPrintOverride}) {
$self->session->output->print($outputPart);
} else {

View file

@ -148,7 +148,7 @@ $canViewMaker->prepare(
},
);
plan tests => 100
plan tests => 103
+ scalar(@fixIdTests)
+ scalar(@fixTitleTests)
+ 2*scalar(@getTitleTests) #same tests used for getTitle and getMenuTitle
@ -678,6 +678,15 @@ $session->setting->set('notFoundPage', $origNotFoundPage);
################################################################
is($rootAsset->get('isExportable'), 1, 'isExportable exists, defaults to 1');
################################################################
#
# getSeparator
#
################################################################
is($rootAsset->getSeparator, '~~~PBasset000000000000001~~~', 'getSeparator, known assetId');
is($rootAsset->getSeparator('!'), '!!!PBasset000000000000001!!!', 'getSeparator, given pad character');
isnt($rootAsset->getSeparator, $mediaFolder->getSeparator, 'getSeparator: unique string');
################################################################
#
# get