Page MenuHomeIn-Portal Phabricator

D334.diff
No OneTemporary

File Metadata

Created
Sat, Apr 19, 7:01 PM

D334.diff

Index: branches/5.2.x/core/kernel/nparser/ntags.php
===================================================================
--- branches/5.2.x/core/kernel/nparser/ntags.php
+++ branches/5.2.x/core/kernel/nparser/ntags.php
@@ -323,7 +323,7 @@
}
$this->Single = false;
$this->OriginalTag = $tag;
- $tag['NP']['name'] = $tag['NP']['design'] . '_' . abs(crc32($tag['file'])) . '_' . $tag['line']; //'__lambda';
+ $tag['NP']['name'] = $this->createSafeFunctionName($tag);
return parent::Open($tag);
}
@@ -341,11 +341,26 @@
return $this->Parser->Buffers[$this->Parser->Level];
}
$o = parent::Close($tag);
- $this->OriginalTag['NP']['name'] = $this->OriginalTag['NP']['design'] . '_' . abs(crc32($this->OriginalTag['file'])) . '_' . $this->OriginalTag['line']; //'__lambda';
+ $this->OriginalTag['NP']['name'] = $this->createSafeFunctionName($this->OriginalTag);
$this->RenderDesignCode($o, $this->OriginalTag['NP']);
return $o;
}
+
+ /**
+ * Creates safe function name based on design used in a given tag.
+ *
+ * @param array $tag Tag.
+ *
+ * @return string
+ */
+ protected function createSafeFunctionName(array $tag)
+ {
+ $safe_design = preg_replace('/[^a-zA-Z0-9_\x7f-\xff]/', '', $tag['NP']['design']);
+
+ return $safe_design . '_' . abs(crc32($tag['file'])) . '_' . $tag['line']; // Former name '__lambda'.
+ }
+
}
class _Tag_RenderElements extends _BlockTag {

Event Timeline