Skip to content

Commit

Permalink
added a package patch "0001-default-identity-encoding.patch" to the tcl
Browse files Browse the repository at this point in the history
package to make the "identity" character encoding the default+system
encoding like it had been with tclsh 8.2 and which seem to have caused
the umlaut character encoding issues recently seen. In addition, adapted
tclrega and tclrpc accordingly so that they only actively perform
character conversion in case no "identity" encoding is used.
Furthermore, remove the explicit "convertto" char conversion calls in
jsonrpc.tcl so fix similar issues. This altogether should hopefully fix
the char encoding issues seen in the WebUI and external CCU addons
like hm_pdetect, etc. This refs #1782.
  • Loading branch information
jens-maus committed Apr 4, 2022

Verified

This commit was signed with the committer’s verified signature.
jens-maus Jens Maus
1 parent 0b50a22 commit e187501
Showing 7 changed files with 65 additions and 28 deletions.
13 changes: 4 additions & 9 deletions buildroot-external/package/tclrega/tclrega.cpp
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@
/*# Definitionen #*/
/*############################################################################*/

#define TCLREGA_VERSION "1.1"
#define TCLREGA_VERSION "1.2"

/*############################################################################*/
/*# Variablen #*/
@@ -141,14 +141,9 @@ int Tclrega_Init (Tcl_Interp* interp) {
/* - - - wernerf - - - */
Tcl_SetVar(interp, "rega_version", TCLREGA_VERSION, TCL_GLOBAL_ONLY);

// get used tcl version
int major;
int minor;
Tcl_GetVersion(&major, &minor, NULL, NULL);

// get iso8859-1 encoding to signal that we need to convert
// from utf8 to iso8859-1 in case we use a tcl version > 8.2
if(major > 8 || (major == 8 && minor > 2)) {
// get the system encoding and then convert to iso8859-1 in
// case the system encoding is not "identity"
if(strcasecmp(Tcl_GetEncodingName(NULL), "identity") != 0) {
iso8859_encoding = Tcl_GetEncoding(interp, "iso8859-1");
}

2 changes: 1 addition & 1 deletion buildroot-external/package/tclrega/tclrega.mk
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
#
################################################################################

TCLREGA_VERSION = 1.1
TCLREGA_VERSION = 1.2
TCLREGA_SITE = $(BR2_EXTERNAL_EQ3_PATH)/package/tclrega
TCLREGA_SITE_METHOD = local
TCLREGA_LICENSE = Apache-2.0
13 changes: 4 additions & 9 deletions buildroot-external/package/tclrpc/tclrpc.cpp
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@

using namespace XmlRpc;

#define TCLRPC_VERSION "1.1"
#define TCLRPC_VERSION "1.2"

static const char* USAGE = "usage: xmlrpc url methodName ?arg1 ?arg2 ...??";

@@ -60,14 +60,9 @@ int DLLEXPORT Tclrpc_Init (Tcl_Interp* interp) {
Tcl_CreateExitHandler( Tclrpc_Exit, 0 );
XmlRpc::XmlRpcErrorHandler::setErrorHandler( &g_tclrpcErrorHandler );

// get used tcl version
int major;
int minor;
Tcl_GetVersion(&major, &minor, NULL, NULL);

// get iso8859-1 encoding to signal that we need to convert
// from utf8 to iso8859-1 in case we use a tcl version > 8.2
if(major > 8 || (major == 8 && minor > 2)) {
// get the system encoding and then convert to iso8859-1 in
// case the system encoding is not "identity"
if(strcasecmp(Tcl_GetEncodingName(NULL), "identity") != 0) {
iso8859_encoding = Tcl_GetEncoding(interp, "iso8859-1");
}

2 changes: 1 addition & 1 deletion buildroot-external/package/tclrpc/tclrpc.mk
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
#
################################################################################

TCLRPC_VERSION = 1.1
TCLRPC_VERSION = 1.2
TCLRPC_SITE = $(BR2_EXTERNAL_EQ3_PATH)/package/tclrpc
TCLRPC_SITE_METHOD = local
TCLRPC_LICENSE = Apache-2.0
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
--- occu/WebUI/www/api/eq3/jsonrpc.tcl.orig
+++ occu/WebUI/www/api/eq3/jsonrpc.tcl
@@ -84,7 +84,11 @@
@@ -41,10 +41,6 @@
proc jsonrpc_error {errorCode errorText} {
global JSONRPC

- set errorCode [encoding convertto identity $errorCode]
- set errorText [encoding convertto identity $errorText]
- set JSONRPC(ID) [encoding convertto identity $JSONRPC(ID)]
-
puts "CONTENT-TYPE: application/json; charset=utf-8"
puts ""
puts "\{"
@@ -72,9 +68,6 @@
proc jsonrpc_response {result} {
global JSONRPC

- set result [encoding convertto identity $result]
- set JSONRPC(ID) [encoding convertto identity $JSONRPC(ID)]
-
puts "CONTENT-TYPE: application/json; charset=utf-8"
puts ""

@@ -84,7 +77,11 @@
puts -nonewline "\"id\": $JSONRPC(ID),"
}
puts -nonewline "\"version\": \"1.1\","
Original file line number Diff line number Diff line change
@@ -41,10 +41,6 @@ proc jsonrpc_parse {request} {
proc jsonrpc_error {errorCode errorText} {
global JSONRPC

set errorCode [encoding convertto identity $errorCode]
set errorText [encoding convertto identity $errorText]
set JSONRPC(ID) [encoding convertto identity $JSONRPC(ID)]

puts "CONTENT-TYPE: application/json; charset=utf-8"
puts ""
puts "\{"
@@ -72,9 +68,6 @@ proc jsonrpc_error {errorCode errorText} {
proc jsonrpc_response {result} {
global JSONRPC

set result [encoding convertto identity $result]
set JSONRPC(ID) [encoding convertto identity $JSONRPC(ID)]

puts "CONTENT-TYPE: application/json; charset=utf-8"
puts ""

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
--- tcl/generic/tclEncoding.c.orig 2022-04-04 10:38:56.350621821 +0200
+++ tcl/generic/tclEncoding.c 2022-04-04 10:37:19.845418339 +0200
@@ -563,6 +563,9 @@
type.clientData = NULL;
tclIdentityEncoding = Tcl_CreateEncoding(&type);

+ defaultEncoding = tclIdentityEncoding;
+ systemEncoding = Tcl_GetEncoding(NULL, type.encodingName);
+
type.encodingName = "utf-8";
type.toUtfProc = UtfExtToUtfIntProc;
type.fromUtfProc = UtfIntToUtfExtProc;
@@ -614,8 +617,7 @@
type.freeProc = TableFreeProc;
type.nullSize = 1;
type.clientData = dataPtr;
- defaultEncoding = Tcl_CreateEncoding(&type);
- systemEncoding = Tcl_GetEncoding(NULL, type.encodingName);
+ Tcl_CreateEncoding(&type);

encodingsInitialized = 1;
}
--- tcl/unix/tclUnixInit.c.orig 2022-04-04 11:21:21.783353703 +0200
+++ tcl/unix/tclUnixInit.c 2022-04-04 11:21:33.023496137 +0200
@@ -94,7 +94,7 @@
*/

#ifndef TCL_DEFAULT_ENCODING
-#define TCL_DEFAULT_ENCODING "iso8859-1"
+#define TCL_DEFAULT_ENCODING "identity"
#endif

/*

0 comments on commit e187501

Please sign in to comment.