Skip to content

Commit

Permalink
Fixes #1046 - change preg delimiter
Browse files Browse the repository at this point in the history
  • Loading branch information
mrook committed Jan 1, 2016
1 parent 1945f02 commit d37471c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion classes/phing/filters/ReplaceTokensWithFile.php
Expand Up @@ -312,7 +312,7 @@ public function read($len = null)

// filter buffer
$buffer = preg_replace_callback(
"/" . preg_quote($this->_beginToken) . "([\w\.\-:\/]+?)" . preg_quote($this->_endToken) . "/",
"$" . preg_quote($this->_beginToken) . "([\w\.\-:\/]+?)" . preg_quote($this->_endToken) . "$",
array($this, 'replaceTokenCallback'),
$buffer
);
Expand Down
12 changes: 12 additions & 0 deletions test/classes/phing/filters/ReplaceTokensWithFileTest.php
Expand Up @@ -44,4 +44,16 @@ public function testPostfix()
'[filter:ReplaceTokensWithFile] Replaced "#!testReplace##" with content from file "testReplace.tpl"'
);
}

/**
* Inspired by ticket #1046 - http://www.phing.info/trac/ticket/1046
*/
public function testSlashInToken()
{
$this->executeTarget(__FUNCTION__);

$this->assertInLogs(
'[filter:ReplaceTokensWithFile] Replaced "//#file:testReplace:endfile#" with content from file "testReplace.tpl"'
);
}
}
12 changes: 12 additions & 0 deletions test/etc/filters/ReplaceTokensWithFile/build.xml
Expand Up @@ -10,4 +10,16 @@
</copy>
<delete file="properties_out.ini"/>
</target>

<target name="testSlashInToken">
<copy file="properties.ini"
tofile="properties_out.ini" overwrite="true">

<filterchain>
<replacetokenswithfile begintoken="//#file:" endtoken=":endfile#"
dir="" postfix=".tpl" />
</filterchain>
</copy>
<delete file="properties_out.ini"/>
</target>
</project>
1 change: 1 addition & 0 deletions test/etc/filters/ReplaceTokensWithFile/properties.ini
@@ -1 +1,2 @@
#!testReplace##
//#file:testReplace:endfile#

0 comments on commit d37471c

Please sign in to comment.