Escaping [ ] characters in message body/footer

Solutions for other advanced phplisters

Escaping [ ] characters in message body/footer

Postby jezdikm » 2:02pm, Fri 12 Oct, 2007

Hi,
I found an interesting problem today. You know [ ] brackets are used for keywords in PHPList. Eg. [PREFERENCES] or [UNSUBSCRIBE] are substituted with links.

Now my problem. I need to have a text like [-CCC-] in my message body/footer.

When I do this, everything is fine. The only problem is the PERFORMANCE as the php is trying to parse the text between [] and it takes a lot of CPU and slows down the processing.

In fact we usually send about 30.000msgs/hour. With this [-CCC-] text in the message the speed decrease to about 7.000msgs/hour.

My question is: Can I somehow escape the brackets so PHPList won't try to find appropriate keyword?

Thank you,
Milan

ps: I can not use &#91 ; entity as I need to have single [ character in the message
jezdikm
phpLister
 
Posts: 12
Joined: 3:31pm, Thu 16 Nov, 2006

Postby H2B2 » 5:03pm, Sun 14 Oct, 2007

This issue has been discussed before, e.g.:
http://forums.phplist.com/viewtopic.php?t=5147
http://mantis.phplist.com/view.php?id=6178

Unfortunately, it appears no one has been able to define a clear solution, besides this workaround for HTML messages (apparently not useful in your case):
phpfan wrote:In the HTML version, using the HTML codes for left square bracket (&# 91;) and right square bracket (&# 93;) works.
Ref: http://forums.phplist.com/viewtopic.php?p=25132#25132
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

A workaround

Postby maxxxie » 3:42am, Sun 23 Mar, 2008

Howdy,

Since I don't plan to use placeholders, I found a small piece of code in lists/admin/sendemaillib.php and commented it out:

Lines 508-510:
Code: Select all
  ## remove any existing placeholders
  $htmlmessage = eregi_replace("\[[A-Z\. ]+\]","",$htmlmessage);
  $textmessage = eregi_replace("\[[A-Z\. ]+\]","",$textmessage);


Change to:
Code: Select all
  ## remove any existing placeholders
  // $htmlmessage = eregi_replace("\[[A-Z\. ]+\]","",$htmlmessage);
  // $textmessage = eregi_replace("\[[A-Z\. ]+\]","",$textmessage);


This prevents removal of square brackets from the text. I have no idea if this breaks anything, but since I don't use placeholders in my newsletters, it seems like a quick and dirty solution.

Cheers,
Max
maxxxie
phpList newbie
 
Posts: 1
Joined: 3:38am, Sun 23 Mar, 2008

Postby ohill » 4:25pm, Tue 24 Jun, 2008

I work around this problem adding 2 lines in the sendemailib.php :

Code: Select all
  $transbracket = array("[" => "[", "]" => "]");
  $textmessage = strtr($textmessage, $transbracket);


just after line 510 refering maxxxie's post.

I use HTML entities [ and ] in my newsletters content/footer/template to add brackets :)
ohill
phpList newbie
 
Posts: 3
Joined: 4:14pm, Tue 24 Jun, 2008

try it like this: [[text]text]

Postby ojrokk » 9:45pm, Mon 02 Feb, 2009

try it like this:

[[text]text]


works for me...not sure why or if it'll break something.
ojrokk
 


Return to Advanced Answers, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 2 guests