Newlines in language strings

Chuck Foster chuck.foster at STREAMSHIELD.COM
Thu Jun 2 15:13:33 IST 2005


    [ The following text is in the "iso-8859-1" character set. ]
    [ Your display is set for the "US-ASCII" character set.  ]
    [ Some characters may be displayed incorrectly. ]

Hi,

One of the patches I need to apply to each new version of MailScanner is a
notification message that I wish to place at the top of each message
generated in the MessageBatch::WarnLocalPostmaster function. Now, in
principle I could get around having to patch the code by using the
'noticeprefix' language string instead; however, that doesn't allow
interpret newlines so I couldn't use this in the way I wanted for that.

Now, how much pain could it cause elsewhere to have the string returned
checked for newlines and subsequently used in output? Indeed, what if that
is taken a step further for %percent% and ENV vars too? I was thinking
something like:


sub DoLineExpansion { # like DoPercentVars but with ENV too
	my ($string) = @_;
	$string =~ s/\%([^%]+)\%/$PercentVars{lc($1)}/g;
	$string =~ s/\$\{?(\w+)\}?/$ENV{$1}/g;
	$string =~ s/\\n/\n/g;
	$string;
}

sub LanguageValue { return &DoLineExpansion( FindLanguageValue( @_ ) ); }


... where the original LanguageValue function is renamed FindLanguageValue;
thus, I could then have a line in languages.conf like:

	Notice Prefix: This is a line blah blah\nwith text on another
line\nFrom %org-long-name%

What could go horribly wrong ... ?!!!

(I guess this expansion could probably be extended to Value() and
QuickPeek() too at some point ...)

Chuck


This message should be regarded as confidential. If you have received this 
email in error please notify the sender and destroy it immediately.
Statements of intent shall only become binding when confirmed in hard copy 
by an authorized signatory.


-- 
This message has been scanned for viruses and potentially
harmful content by StreamShield Protector.

------------------------ MailScanner list ------------------------
To unsubscribe, email jiscmail at jiscmail.ac.uk with the words:
'leave mailscanner' in the body of the email.
Before posting, read the Wiki (http://wiki.mailscanner.info/) and
the archives (http://www.jiscmail.ac.uk/lists/mailscanner.html).

Support MailScanner development - buy the book off the website!




More information about the MailScanner mailing list