Item10236: overoptimized regex in _replaceTypeTags breaks replaceAllTags

pencil
Priority: Normal
Current State: Closed
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: TocPlugin
Branches:
Reported By: DiabJerius
Waiting For:
Last Change By: CrawfordCurrie
Symptom:

The %CONTENTS% link is not being replaced by the error message if there is a problem in WebOrder.

How to Replicate:

Create a WebOrder topic that looks like this:
%ANCHOR%
%REFTABLE%
%CONTENTS%
%TOCCHECK%

   * Introduction
   * Introduction

When you view it you will see something that looks like this:

.

This is incorrect. It should look like this:

.

Solution:

The problem is that the regexp used to replace tags in TocPlugin::Section::_replaceTypeTags is overoptimized. Here's the code:

    598 # remove tags of a given type from a string
    599 sub _replaceTypeTags {
    600     my ($type, $text, $alt) = @_;
    601     $text =~ s/%$type({[^%]*})?%/$alt/geo;
    602     return $text;
    603 }
    604 

Note the geo modifier in line 601. This freezes the string for the very first value of $type, preventing any further successful replacement for any other value of $type. _replaceTypeTags is called only by _replaceAllTags=, which calls it with the tags in the order specified in the above example WebOrder topic. The fix is simple. Remove the o from geo on line 601.

-- DiabJerius - 10 Jan 2011

Done

-- CrawfordCurrie - 24 Mar 2011

 

ItemTemplate edit

Summary overoptimized regex in _replaceTypeTags breaks replaceAllTags
ReportedBy DiabJerius
Codebase
SVN Range
AppliesTo Extension
Component TocPlugin
Priority Normal
CurrentState Closed
WaitingFor
Checkins TocPlugin:407f86328495
TargetRelease n/a
ReleasedIn n/a
I Attachment Action Size Date Who Comment
after.pngpng after.png manage 6 K 10 Jan 2011 - 21:03 DiabJerius  
before.pngpng before.png manage 6 K 10 Jan 2011 - 21:03 DiabJerius  
Topic revision: r2 - 24 Mar 2011, CrawfordCurrie
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