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".

CommentFileSizeAuthor
#2 packer-apply-regexp-183871-2.patch814 bytesbjaspan

Comments

bjaspan’s picture

The 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.

bjaspan’s picture

Status: Active » Needs review
StatusFileSize
new814 bytes

I actually think packer should be removed from core (see http://drupal.org/node/183940) but, until then, here's a patch.

steven jones’s picture

Status: Needs review » Closed (won't fix)

We removed packer from core, so this isn't an issue any more.