[ic] MV-UTF8
David Christensen
david at endpoint.com
Wed Feb 25 17:38:48 UTC 2009
>>> Add below to interchange.cfg
>>>
>>> Variable MV_HTTP_CHARSET 1
>>
>> This should be set to UTF-8, and should be in catalog.cfg as well
>> as the
>> below settings. Setting that variable to "1" could definately
>> cause you
>> problems.
>
> I suppose we should check whether the charset is valid at all at
> configuration time.
>
> Regards
> Racke
First draft approach:
From c08f3f73d73c2ccc75ff013ab1de6cfd2a61c92b Mon Sep 17 00:00:00 2001
From: David Christensen <david at endpoint.com>
Date: Wed, 25 Feb 2009 11:30:22 -0600
Subject: [PATCH] Added validation of user-provided MV_HTTP_CHARSET
variable, if it exists
---
lib/Vend/Config.pm | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/lib/Vend/Config.pm b/lib/Vend/Config.pm
index 4f8a5f6..f85d16c 100644
--- a/lib/Vend/Config.pm
+++ b/lib/Vend/Config.pm
@@ -53,6 +53,7 @@ use Vend::Util;
use Vend::File;
use Vend::Data;
use Vend::Cron;
+use Vend::CharSet ();
$VERSION = substr(q$Revision: 2.240 $, 10);
@@ -1341,6 +1342,21 @@ CONFIGLOOP:
set_readonly_config();
# Ugly legacy stuff so API won't break
$C->{Special} = $C->{SpecialPage} if defined $C->{SpecialPage};
+
+ # check MV_HTTP_CHARSET against a valid encoding
+ if (my $enc = $C->{Variable}->{MV_HTTP_CHARSET}) {
+ if (my $norm_enc = Vend::CharSet->validate_encoding($enc)) {
+ if ($norm_enc ne $enc) {
+ config_warn("Provided MV_HTTP_CHARSET '$enc' resolved
to '$norm_enc'. Continuing.");
+ $C->{Variable}->{MV_HTTP_CHARSET} = $norm_enc;
+ }
+ }
+ else {
+ config_error("Unrecognized/unsupported MV_HTTP_CHARSET:
'%s'.", $enc);
+ delete $C->{Variable}->{MV_HTTP_CHARSET};
+ }
+ }
+
my $return = $C;
undef $C;
return $return;
--
1.6.2.rc0.14.g02bf
Regards,
David
--
David Christensen
End Point Corporation
david at endpoint.com
212-929-6923
http://www.endpoint.com/
More information about the interchange-users
mailing list