Page MenuHomePhabricator

D14170.id34237.diff
No OneTemporary

D14170.id34237.diff

diff --git a/src/utils/PhutilCowsay.php b/src/utils/PhutilCowsay.php
--- a/src/utils/PhutilCowsay.php
+++ b/src/utils/PhutilCowsay.php
@@ -45,11 +45,13 @@
// (and any comments in the file) away.
$template = phutil_split_lines($template, true);
$keep = array();
+ $is_perl_cowfile = false;
foreach ($template as $key => $line) {
if (preg_match('/^#/', $line)) {
continue;
}
if (preg_match('/^\s*\\$the_cow/', $line)) {
+ $is_perl_cowfile = true;
continue;
}
if (preg_match('/^\s*EOC\s*$/', $line)) {
@@ -59,6 +61,16 @@
}
$template = implode('', $keep);
+ // Original .cow files are perl scripts which contain escaped sequences.
+ // We attempt to unescape here by replacing any character preceded by a
+ // backslash/escape with just that character.
+ if ($is_perl_cowfile) {
+ $template = preg_replace(
+ '/\\\\(.)/',
+ '$1',
+ $template);
+ }
+
$template = preg_replace_callback(
'/\\$([a-z]+)/',
array($this, 'replaceTemplateVariable'),

File Metadata

Mime Type
text/plain
Expires
Fri, Mar 14, 4:31 PM (4 d, 15 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7662116
Default Alt Text
D14170.id34237.diff (1 KB)

Event Timeline