]> SAFE projects GIT repository - jmp/mailleur/commitdiff
DB check UTF format is working
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sat, 28 Jun 2025 17:07:11 +0000 (13:07 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sat, 28 Jun 2025 17:07:11 +0000 (13:07 -0400)
data-feed/feed04.tst
lib/devsql.c
lib/unisql.c

index c64e5ab1e81e109730dfde5a3bb2244426c3cc4d..831c63815940e96300632ff72e5681223e71de09 100644 (file)
@@ -5,8 +5,8 @@ S:HELO example.com
 R:250 mailleur.example.com, link (cleartext) ready,...
 S:MAIL FROM: <postmaster@example.com>
 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: <utf8-áöüñ@example.com>
+R:250 2.6.4 Address accepted <utf8-áöüñ@example.com>
 #-------------------------------------------------------------------------
 #-sending data
 C:DATA 354 3.5.0 End data with <CR><LF>.<CR><LF>
index 177d14e976b2815d9099a0bf81d77728e771a055..46b8699aae321d5f9c0c4f833cad63806442574e 100644 (file)
@@ -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;
index 184b34b44d58595951317675b91a8a0131903e57..cd1971f6def6348b8d35f8cd03a97d6cb0d989d8 100644 (file)
@@ -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;