Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F847850
D334.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Apr 19, 7:01 PM
Size
1 KB
Mime Type
text/x-diff
Expires
Sun, Apr 20, 7:01 PM (16 m, 41 s)
Engine
blob
Format
Raw Data
Handle
602636
Attached To
D334: INP-1735 - Normalize block parameter values, used during function name creation
D334.diff
View Options
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
Log In to Comment