There is a bug in _packer_apply(). The replacement text (e.g.) "\$0\n" matches the regexp /^\$\d+$/ (because the $ can match a single trailing newline) and so it triggers the optimized replacement method instead of the normal one. The result is that '$0' gets substituted, not "\$0\n".
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | packer-apply-regexp-183871-2.patch | 814 bytes | bjaspan |
Comments
Comment #1
bjaspan commentedThe fix is to replace the regexp
/^\$\d+$/with /\A\$\d+\z/. \A matches start-of-string and \z matches end-of-string, independent of line mode. Thus, \z will not accept the trailing newline in the text case I posted and correctly fail to match.Comment #2
bjaspan commentedI actually think packer should be removed from core (see http://drupal.org/node/183940) but, until then, here's a patch.
Comment #3
steven jones commentedWe removed packer from core, so this isn't an issue any more.