Skip to content

Commit

Permalink
Bug #5397 variable used inside single quotes bugs WikiLinks
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.php.net/repository/pear/packages/Text_Wiki/trunk@196041 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
bertrand Gugger committed Sep 14, 2005
1 parent 826f5e9 commit 9a5d779
Showing 1 changed file with 49 additions and 49 deletions.
98 changes: 49 additions & 49 deletions Text/Wiki/Parse/Default/Wikilink.php
@@ -1,23 +1,23 @@
<?php

/**
*
*
* Parse for links to wiki pages.
*
*
* @category Text
*
*
* @package Text_Wiki
*
*
* @author Paul M. Jones <pmjones@php.net>
*
*
* @license LGPL
*
*
* @version $Id$
*
*
*/

/**
*
*
* Parse for links to wiki pages.
*
* Wiki page names are typically in StudlyCapsStyle made of
Expand All @@ -29,42 +29,42 @@
* The token options for this rule are:
*
* 'page' => the wiki page name.
*
*
* 'text' => the displayed link text.
*
*
* 'anchor' => a named anchor on the target wiki page.
*
*
* @category Text
*
*
* @package Text_Wiki
*
*
* @author Paul M. Jones <pmjones@php.net>
*
*
*/

class Text_Wiki_Parse_Wikilink extends Text_Wiki_Parse {

var $conf = array (
'ext_chars' => false
);

/**
*
*
* Constructor.
*
*
* We override the Text_Wiki_Parse constructor so we can
* explicitly comment each part of the $regex property.
*
*
* @access public
*
*
* @param object &$obj The calling "parent" Text_Wiki object.
*
*
*/

function Text_Wiki_Parse_Wikilink(&$obj)
{
parent::Text_Wiki_Parse($obj);

if ($this->getConf('ext_chars')) {
// use an extended character set; this should
// allow for umlauts and so on. taken from the
Expand All @@ -79,7 +79,7 @@ function Text_Wiki_Parse_Wikilink(&$obj)
$lower = "a-z0-9";
$either = "A-Za-z0-9";
}

// build the regular expression for finding WikiPage names.
$this->regex =
"(!?" . // START WikiPage pattern (1)
Expand All @@ -96,18 +96,18 @@ function Text_Wiki_Parse_Wikilink(&$obj)
"[-_$either]" . // 1 dash, alpha, digit, or underscore
")?)?)"; // end subpatterns (/4)(/3)(/2)
}


/**
*
*
* First parses for described links, then for standalone links.
*
*
* @access public
*
*
* @return void
*
*
*/

function parse()
{
// described wiki links
Expand All @@ -117,27 +117,27 @@ function parse()
array(&$this, 'processDescr'),
$this->wiki->source
);

// standalone wiki links
if ($this->getConf('ext_chars')) {
$either = "A-Za-z0-9\xc0-\xfe";
} else {
$either = "A-Za-z0-9";
}
$tmp_regex = '/(^|[^$either\-_])' . $this->regex . '/';

$tmp_regex = "/(^|[^{$either}\-_]){$this->regex}/";
$this->wiki->source = preg_replace_callback(
$tmp_regex,
array(&$this, 'process'),
$this->wiki->source
);
}


/**
*
*
* Generate a replacement for described links.
*
*
* @access public
*
* @param array &$matches The array of matches from parse().
Expand All @@ -146,7 +146,7 @@ function parse()
* the source text, plus any text priot to the match.
*
*/

function processDescr(&$matches)
{
// set the options
Expand All @@ -155,17 +155,17 @@ function processDescr(&$matches)
'text' => $matches[5],
'anchor' => $matches[3]
);

// create and return the replacement token and preceding text
return $this->wiki->addToken($this->rule, $options); // . $matches[7];
}


/**
*
*
* Generate a replacement for standalone links.
*
*
*
*
* @access public
*
* @param array &$matches The array of matches from parse().
Expand All @@ -174,24 +174,24 @@ function processDescr(&$matches)
* the source text, plus any text prior to the match.
*
*/

function process(&$matches)
{
// when prefixed with !, it's explicitly not a wiki link.
// return everything as it was.
if ($matches[2]{0} == '!') {
return $matches[1] . substr($matches[2], 1) . $matches[3];
}

// set the options
$options = array(
'page' => $matches[2],
'text' => $matches[2] . $matches[3],
'anchor' => $matches[3]
);

// create and return the replacement token and preceding text
return $matches[1] . $this->wiki->addToken($this->rule, $options);
}
}
?>
?>

0 comments on commit 9a5d779

Please sign in to comment.