]> wagnertech.de Git - kivitendo-erp.git/commitdiff
Die JavaScript-Funktion "encodeURIComponent()" benutzt immer UTF-8 als Zeichensatz...
authorMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 16 Mar 2009 17:25:15 +0000 (17:25 +0000)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 16 Mar 2009 17:25:15 +0000 (17:25 +0000)
15 files changed:
SL/Form.pm
js/calculate_qty.js
js/common.js
js/customer_or_vendor_selection.js
js/delivery_customer_selection.js
js/dunning.js
js/follow_up.js
js/part_selection.js
js/parts_language_selection.js
js/show_history.js
js/show_vc_details.js
js/stock_in_out.js
js/vendor_selection.js
templates/webpages/admin/edit_user_de.html
templates/webpages/admin/edit_user_master.html

index 355d60aef9123f94b8ac5406af9ee1163b3db1ac..71af15e1dcf2c748d58edf0ebe2ddef2c78eed0e 100644 (file)
@@ -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;
index 4a7f91bccb0099406d1219391b8d8bfa01d76a05..a3bf3ad5d94075dcc8928206e02174bd240b79f1 100644 (file)
@@ -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) + "&" +
index 6d818f312fed73aac0009e9826333e939bb2121e..8decd61f29c8f866919d8250e3d37118d5800d53 100644 (file)
@@ -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) + "&"
index 2e169805567d922797998279b7d5be160c37814a..b09183f7c0d0540aa12a4f4323574f4d78ce1e69 100644 (file)
@@ -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) + "&" +
index c44b3385e313a834a4007488904bf157df2f1d31..89f7740ea7bc63d4d8a6ce0833997e6b2e0ba6f2 100644 (file)
@@ -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) + "&" +
index ccf80c6919161cf4f696c1953f0988b39f53e1e4..9a794a985cf37c353e95e7395e61cb79b836464a 100644 (file)
@@ -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) + "&" +
index 379c7168480b0e422158bdf18eab6e19bf723dfe..4b11dcdb5ccdedc8505440253276df686cadceeb 100644 (file)
@@ -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";
 
index 3e0c50037ad3d4b2fbfbacdf242b313d8c4f89ff..9ce022cd5b6466d6859b8135b36d5882562e6629 100644 (file)
@@ -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)       + "&" +
index de5dafdbece093a72d58a37ad0a2f8e720009dad..a0607165f00abc3c1f220a8b7283f20a48661023 100644 (file)
@@ -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) + "&" +
index 55912590e1d4f680e4f99c52f13e3e0ae3339fff..e0cfec45e61dcc6ae9296a2e812c1f1d947d17a3 100644 (file)
@@ -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) + "&"
index 3e5bffc01b2a6f1a60d5b38fb63fc938ae0714ac..067a264cd57fe447d0ceb565db03a27d125c4601 100644 (file)
@@ -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)
index 93d120a05a2d3a57b800f862dff8b3fe7eb8010c..5cffa3d889dd4c4086c2211c7c5a3e757ce71fc1 100644 (file)
@@ -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)       + "&" +
index 298635770cd49eda4b773efa6fcf678ea2c157fd..3d98f4b3d9cdbd73f4603853b0420e37101a0820 100644 (file)
@@ -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) + "&" +
index 3b7667104d00fa9d0a6b997f68085879c27ccbd1..b35b8da6d6d1a6b83ca62406d405c0f55b98cf28 100644 (file)
@@ -5,7 +5,7 @@
   <!--
       function open_connection_test_window() {
         // host name port user passwd
-        var url = "admin.pl?action=test_db_connection&" +
+        var url = "admin.pl?INPUT_ENCODING=UTF-8&action=test_db_connection&" +
           "dbhost="   + encodeURIComponent(get_input_value("dbhost"))   + "&" +
           "dbport="   + encodeURIComponent(get_input_value("dbport"))   + "&" +
           "dbname="   + encodeURIComponent(get_input_value("dbname"))   + "&" +
index 92152a792b950b90b0bcb2d88b9f71e64c5feec8..2bc4ec84d5edbab3ed4a3595edf79f26304e7456 100644 (file)
@@ -5,7 +5,7 @@
   <!--
       function open_connection_test_window() {
         // host name port user passwd
-        var url = "admin.pl?action=test_db_connection&" +
+        var url = "admin.pl?INPUT_ENCODING=UTF-8&action=test_db_connection&" +
           "dbhost="   + encodeURIComponent(get_input_value("dbhost"))   + "&" +
           "dbport="   + encodeURIComponent(get_input_value("dbport"))   + "&" +
           "dbname="   + encodeURIComponent(get_input_value("dbname"))   + "&" +