From: Moritz Bunkus Date: Mon, 16 Mar 2009 17:25:15 +0000 (+0000) Subject: Die JavaScript-Funktion "encodeURIComponent()" benutzt immer UTF-8 als Zeichensatz... X-Git-Tag: release-2.6.0beta2~136 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=5d5572546c7e33b5f573227f23973ec7668bafe2;p=kivitendo-erp.git Die JavaScript-Funktion "encodeURIComponent()" benutzt immer UTF-8 als Zeichensatz, egal, was die HTTP-Header oder das
-Element sagen. Also muss der Input bei Erhalt in den Zeichensatz der Installation konvertiert werden. --- diff --git a/SL/Form.pm b/SL/Form.pm index 355d60aef..71af15e1d 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -70,12 +70,10 @@ END { sub _store_value { $main::lxdebug->enter_sub(2); - my $self = shift; + my $curr = shift; my $key = shift; my $value = shift; - my $curr = $self; - while ($key =~ /\[\+?\]\.|\./) { substr($key, 0, $+[0]) = ''; @@ -103,14 +101,14 @@ sub _store_value { sub _input_to_hash { $main::lxdebug->enter_sub(2); - my $self = shift; - my $input = shift; + my $params = shift; + my $input = shift; - my @pairs = split(/&/, $input); + my @pairs = split(/&/, $input); foreach (@pairs) { my ($key, $value) = split(/=/, $_, 2); - $self->_store_value($self->unescape($key), $self->unescape($value)); + _store_value($params, unescape(undef, $key), unescape(undef, $value)); } $main::lxdebug->leave_sub(2); @@ -119,13 +117,13 @@ sub _input_to_hash { sub _request_to_hash { $main::lxdebug->enter_sub(2); - my $self = shift; - my $input = shift; + my $params = shift; + my $input = shift; if (!$ENV{'CONTENT_TYPE'} || ($ENV{'CONTENT_TYPE'} !~ /multipart\/form-data\s*;\s*boundary\s*=\s*(.+)$/)) { - $self->_input_to_hash($input); + _input_to_hash($params, $input); $main::lxdebug->leave_sub(2); return; @@ -173,8 +171,8 @@ sub _request_to_hash { substr $line, $-[0], $+[0] - $-[0], ""; } - $previous = $self->_store_value($name, ''); - $self->{FILENAME} = $filename if ($filename); + $previous = _store_value($params, $name, ''); + $params->{FILENAME} = $filename if ($filename); next; } @@ -196,6 +194,29 @@ sub _request_to_hash { $main::lxdebug->leave_sub(2); } +sub _recode_recursively { + my ($iconv, $param) = @_; + + if (ref $param eq 'HASH') { + foreach my $key (keys %{ $param }) { + if (!ref $param->{$key}) { + $param->{$key} = $iconv->convert($param->{$key}); + } else { + _recode_recursively($iconv, $param->{$key}); + } + } + + } elsif (ref $param eq 'ARRAY') { + foreach my $idx (0 .. scalar(@{ $param }) - 1) { + if (!ref $param->[$idx]) { + $param->[$idx] = $iconv->convert($param->[$idx]); + } else { + _recode_recursively($iconv, $param->[$idx]); + } + } + } +} + sub new { $main::lxdebug->enter_sub(); @@ -220,7 +241,22 @@ sub new { bless $self, $type; - $self->_request_to_hash($_); + my $parameters = { }; + _request_to_hash($parameters, $_); + + my $db_charset = $main::dbcharset; + $db_charset ||= Common::DEFAULT_CHARSET; + + if ($parameters->{INPUT_ENCODING} && (lc $parameters->{INPUT_ENCODING} ne $db_charset)) { + require Text::Iconv; + my $iconv = Text::Iconv->new($parameters->{INPUT_ENCODING}, $db_charset); + + _recode_recursively($iconv, $parameters); + + delete $parameters{INPUT_ENCODING}; + } + + map { $self->{$_} = $parameters->{$_}; } keys %{ $parameters }; $self->{action} = lc $self->{action}; $self->{action} =~ s/( |-|,|\#)/_/g; diff --git a/js/calculate_qty.js b/js/calculate_qty.js index 4a7f91bcc..a3bf3ad5d 100644 --- a/js/calculate_qty.js +++ b/js/calculate_qty.js @@ -7,6 +7,7 @@ function calculate_qty_selection_window(input_name, alu, formel, row) { var description = document.getElementsByName("description_" + row)[0].value; } else var action = "calculate_qty"; url = "common.pl?" + + "INPUT_ENCODING=UTF-8&" + "action=" + action + "&" + "name=" + encodeURIComponent(name) + "&" + "input_name=" + encodeURIComponent(input_name) + "&" + diff --git a/js/common.js b/js/common.js index 6d818f312..8decd61f2 100644 --- a/js/common.js +++ b/js/common.js @@ -42,6 +42,7 @@ function set_longdescription_window(input_name) { var parm = centerParms(600,500) + ",width=600,height=500,status=yes,scrollbars=yes"; var name = document.getElementsByName(input_name)[0].value; url = "common.pl?" + + "INPUT_ENCODING=UTF-8&" + "action=set_longdescription&" + "longdescription=" + encodeURIComponent(document.getElementsByName(input_name)[0].value) + "&" + "input_name=" + encodeURIComponent(input_name) + "&" diff --git a/js/customer_or_vendor_selection.js b/js/customer_or_vendor_selection.js index 2e1698055..b09183f7c 100644 --- a/js/customer_or_vendor_selection.js +++ b/js/customer_or_vendor_selection.js @@ -2,6 +2,7 @@ function customer_or_vendor_selection_window(input_name, input_id, is_vendor, al var parm = centerParms(800,600) + ",width=800,height=600,status=yes,scrollbars=yes"; var name = document.getElementsByName(input_name)[0].value; url = "common.pl?" + + "INPUT_ENCODING=UTF-8&" + "action=cov_selection_internal&" + "name=" + encodeURIComponent(name) + "&" + "input_name=" + encodeURIComponent(input_name) + "&" + diff --git a/js/delivery_customer_selection.js b/js/delivery_customer_selection.js index c44b3385e..89f7740ea 100644 --- a/js/delivery_customer_selection.js +++ b/js/delivery_customer_selection.js @@ -2,6 +2,7 @@ function delivery_customer_selection_window(input_name, input_id) { var parm = centerParms(600,500) + ",width=600,height=500,status=yes,scrollbars=yes"; var name = document.getElementsByName(input_name)[0].value; url = "common.pl?" + + "INPUT_ENCODING=UTF-8&" + "action=delivery_customer_selection&" + "name=" + encodeURIComponent(name) + "&" + "input_name=" + encodeURIComponent(input_name) + "&" + diff --git a/js/dunning.js b/js/dunning.js index ccf80c691..9a794a985 100644 --- a/js/dunning.js +++ b/js/dunning.js @@ -1,6 +1,7 @@ function set_email_window(input_subject, input_body, input_attachment) { var parm = centerParms(800,600) + ",width=800,height=600,status=yes,scrollbars=yes"; var url = "dn.pl?" + + "INPUT_ENCODING=UTF-8&" + "action=set_email&" + "email_subject=" + encodeURIComponent(document.getElementsByName(input_subject)[0].value) + "&" + "email_body=" + encodeURIComponent(document.getElementsByName(input_body)[0].value) + "&" + diff --git a/js/follow_up.js b/js/follow_up.js index 379c71684..4b11dcdb5 100644 --- a/js/follow_up.js +++ b/js/follow_up.js @@ -4,6 +4,7 @@ function follow_up_window() { var parm = centerParms(width, height) + ",width=" + width + ",height=" + height + ",status=yes,scrollbars=yes"; url = "fu.pl?" + + "INPUT_ENCODING=UTF-8&" + "action=add" + "&" + "POPUP_MODE=1"; diff --git a/js/part_selection.js b/js/part_selection.js index 3e0c50037..9ce022cd5 100644 --- a/js/part_selection.js +++ b/js/part_selection.js @@ -24,6 +24,7 @@ function part_selection_window(input_partnumber, input_description, input_partsi options = ""; url = "common.pl?" + + "INPUT_ENCODING=UTF-8&" + "action=part_selection_internal&" + "partnumber=" + encodeURIComponent(partnumber) + "&" + "description=" + encodeURIComponent(description) + "&" + diff --git a/js/parts_language_selection.js b/js/parts_language_selection.js index de5dafdbe..a0607165f 100644 --- a/js/parts_language_selection.js +++ b/js/parts_language_selection.js @@ -2,6 +2,7 @@ function parts_language_selection_window(input_name) { var parm = centerParms(600,500) + ",width=600,height=500,status=yes,scrollbars=yes"; var name = document.getElementsByName(input_name)[0].value; url = "ic.pl?" + + "INPUT_ENCODING=UTF-8&" + "action=parts_language_selection&" + "id=" + encodeURIComponent(document.ic.id.value) + "&" + "language_values=" + encodeURIComponent(document.ic.language_values.value) + "&" + diff --git a/js/show_history.js b/js/show_history.js index 55912590e..e0cfec45e 100644 --- a/js/show_history.js +++ b/js/show_history.js @@ -14,6 +14,7 @@ function set_history_window(id) { var parm = centerParms(800,500) + ",width=800,height=500,status=yes,scrollbars=yes"; var name = "History"; url = "common.pl?" + + "INPUT_ENCODING=UTF-8&" + "action=show_history&" + "longdescription=" + "&" + "input_name=" + encodeURIComponent(id) + "&" diff --git a/js/show_vc_details.js b/js/show_vc_details.js index 3e5bffc01..067a264cd 100644 --- a/js/show_vc_details.js +++ b/js/show_vc_details.js @@ -6,6 +6,7 @@ function show_vc_details(vc) { if (vc_id) vc_id = vc_id[0].value; url = "common.pl?" + + "INPUT_ENCODING=UTF-8&" + "action=show_vc_details&" + "vc=" + encodeURIComponent(vc) + "&" + "vc_id=" + encodeURIComponent(vc_id) diff --git a/js/stock_in_out.js b/js/stock_in_out.js index 93d120a05..5cffa3d88 100644 --- a/js/stock_in_out.js +++ b/js/stock_in_out.js @@ -11,6 +11,7 @@ function open_stock_in_out_window(in_out, row) { var delivered = document.getElementsByName("delivered")[0].value; url = "do.pl?" + + "INPUT_ENCODING=UTF-8&" + "action=stock_in_out_form&" + "in_out=" + encodeURIComponent(in_out) + "&" + "row=" + encodeURIComponent(row) + "&" + diff --git a/js/vendor_selection.js b/js/vendor_selection.js index 298635770..3d98f4b3d 100644 --- a/js/vendor_selection.js +++ b/js/vendor_selection.js @@ -2,6 +2,7 @@ function vendor_selection_window(input_name, input_id) { var parm = centerParms(600,500) + ",width=600,height=500,status=yes,scrollbars=yes"; var name = document.getElementsByName(input_name)[0].value; url = "common.pl?" + + "INPUT_ENCODING=UTF-8&" + "action=vendor_selection&" + "name=" + encodeURIComponent(name) + "&" + "input_name=" + encodeURIComponent(input_name) + "&" + diff --git a/templates/webpages/admin/edit_user_de.html b/templates/webpages/admin/edit_user_de.html index 3b7667104..b35b8da6d 100644 --- a/templates/webpages/admin/edit_user_de.html +++ b/templates/webpages/admin/edit_user_de.html @@ -5,7 +5,7 @@