From 48d8f3c0e0068d54f8d32c7e3373d6fe9f71c429 Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Sat, 28 Jun 2025 13:07:11 -0400 Subject: [PATCH] DB check UTF format is working --- data-feed/feed04.tst | 4 ++-- lib/devsql.c | 2 +- lib/unisql.c | 26 +++++++++++++------------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/data-feed/feed04.tst b/data-feed/feed04.tst index c64e5ab..831c638 100644 --- a/data-feed/feed04.tst +++ b/data-feed/feed04.tst @@ -5,8 +5,8 @@ S:HELO example.com R:250 mailleur.example.com, link (cleartext) ready,... S:MAIL FROM: R:250 2.1.3 postmaster@example.com.. sender ok -S:RCPT TO: <áöüñ@example.com> -R:250 2.6.4 Address accepted <áöüñ@example.com> +S:RCPT TO: +R:250 2.6.4 Address accepted #------------------------------------------------------------------------- #-sending data C:DATA 354 3.5.0 End data with . diff --git a/lib/devsql.c b/lib/devsql.c index 177d14e..46b8699 100644 --- a/lib/devsql.c +++ b/lib/devsql.c @@ -258,7 +258,7 @@ static USRTYP *select_user(SQLTYP *sql,char *email) { #define OPEP "devsql.c:select_user," -#define SELUSR "SELECT * FROM "EMAILS" WHERE email='%s'" +#define SELUSR "SELECT * FROM "EMAILS" WHERE email=%s" USRTYP *usr; SQLRES *rs; diff --git a/lib/unisql.c b/lib/unisql.c index 184b34b..cd1971f 100644 --- a/lib/unisql.c +++ b/lib/unisql.c @@ -66,13 +66,16 @@ while (proceed==true) { inbuf=encoded; marker=(char *)calloc(outbuflft,sizeof(char)); outbuf=marker; - if (iconv(hconv,&inbuf,&inbuflft,&outbuf,&outbuflft)==(size_t)(-1)) { - (void) rou_alert(2,"%s Unable to convert <%s> " - "from=<%s> to=<%s> (errno=<%s>)", - OPEP,encoded,lfrom,lto,strerror(errno)); - (void) free(marker); - marker=(char *)0; - } + while (inbuflft>0) { + if (iconv(hconv,&inbuf,&inbuflft,&outbuf,&outbuflft)==(size_t)(-1)) { + inbuf++; + inbuflft=strlen(inbuf); + //replacing out of lfrom subset char by '_' + (void) strcat(marker,"_"); + outbuf++; + outbuflft--; + } + } break; case 2 : /*doing convertion */ if (iconv_close(hconv)<0) @@ -86,6 +89,7 @@ while (proceed==true) { } phase++; } +(void) rou_alert(0,"%s encoded=<%s> Converted=<%s>",OPEP,encoded,converted); return converted; #undef OPEP @@ -162,14 +166,10 @@ while (proceed==true) { ptr=DLANG; break; case 1 : - if ((converted=cnvconvert(DLANG,ptr,strencoded))!=(char *)0) + if ((converted=cnvconvert(ptr,ptr,strencoded))!=(char *)0) phase=999; //everything fine converting to DB_LANG break; - case 2 : //converting in very plain ascii - if ((converted=cnvconvert(DLANG,ptr,strencoded))!=(char *)0) - phase=999; //simple char now - break; - case 3 : //conversion trouble + case 2 : //conversion trouble (void) rou_alert(0,"%s Wrong encoding for db access key <%s> (Config?)", OPEP,strencoded); break; -- 2.47.3