lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lynx-dev Handling of untranslatable charset


From: Klaus Weide
Subject: lynx-dev Handling of untranslatable charset
Date: Sat, 16 Jan 1999 02:25:31 -0600 (CST)

Handling of untranslatable charsets was wrong.  I first noticed
when a page with charset=ISO-2022-JP produced an alert message
with a truncated "iso-2022-j".  Looking more closely, the code
could also result in memory corruption in some cases.

I looked at older versions, then changed the code to something
somewhat like what was intended there. But we don't have an
"Other ISO Latin" display character set any more; maybe those
`else' blocks should just have disappeared completely.

    Klaus

(Patch against recent dev code)

*** lynx2-8-2.old/WWW/Library/Implementation/HTMIME.c   Thu Dec  3 12:28:20 1998
--- lynx2-8-2/WWW/Library/Implementation/HTMIME.c       Sat Jan 16 01:58:13 1999
***************
*** 380,386 ****
                                                            UCT_SETBY_DEFAULT);
                                }
                            }
-                           FREE(cp3);
                            if (chartrans_ok) {
                                LYUCcharset * p_in =
                                    HTAnchor_getUCInfoStage(me->anchor,
--- 380,385 ----
***************
*** 428,445 ****
                                }
                            } else {
                                /*
!                               **  Hope it's a match, for now. - FM
                                */
!                               *cp1 = '\0';
!                               me->format = HTAtom_for(cp);
!                               cp1 = &cp4[10];
!                               while (*cp1 &&
!                                      isdigit((unsigned char)(*cp1)))
!                                   cp1++;
!                               *cp1 = '\0';
!                               StrAllocCopy(me->anchor->charset, cp4);
!                               HTPassEightBitRaw = TRUE;
!                               HTAlert(me->anchor->charset);
                            }
                            FREE(cp3);
                        } else {
--- 427,470 ----
                                }
                            } else {
                                /*
!                               **  Cannot translate.
!                               **  If according to some heuristic the given
!                               **  charset and the current display character
!                               **  both are likely to be like ISO-8859 in
!                               **  structure, pretend we have some kind
!                               **  of match.
                                */
!                               BOOL given_is_8859
!                                   = (!strncmp(cp4, "iso-8859-", 9) &&
!                                      isdigit((unsigned char)cp4[9]));
!                               BOOL given_is_8859like
!                                   = (given_is_8859 ||
!                                      !strncmp(cp4, "windows-", 10) ||
!                                      !strncmp(cp4, "cp12", 4) ||
!                                      !strncmp(cp4, "cp-12", 5));
!                               BOOL given_and_display_8859like
!                                   = (given_is_8859like &&
!                                      
(strstr(LYchar_set_names[current_char_set],
!                                              "ISO-8859") ||
!                                       
strstr(LYchar_set_names[current_char_set],
!                                              "windows-")));
! 
!                               if (given_and_display_8859like) {
!                                   *cp1 = '\0';
!                                   me->format = HTAtom_for(cp);
!                               }
!                               if (given_is_8859) {
!                                   cp1 = &cp4[10];
!                                   while (*cp1 &&
!                                          isdigit((unsigned char)(*cp1)))
!                                       cp1++;
!                                   *cp1 = '\0';
!                               }
!                               if (given_and_display_8859like) {
!                                   StrAllocCopy(me->anchor->charset, cp4);
!                                   HTPassEightBitRaw = TRUE;
!                               }
!                               HTAlert(*cp4 ? cp4 : me->anchor->charset);
                            }
                            FREE(cp3);
                        } else {
*** lynx2-8-2.old/WWW/Library/Implementation/HTFile.c   Thu Dec 24 05:27:23 1998
--- lynx2-8-2/WWW/Library/Implementation/HTFile.c       Sat Jan 16 01:33:57 1999
***************
*** 933,950 ****
            }
        } else {
            /*
!           **  Hope it's a match, for now. - FM
            */
!           *cp1 = '\0';
!           format = HTAtom_for(cp);
!           cp1 = &cp4[10];
!           while (*cp1 &&
!                  isdigit((unsigned char)(*cp1)))
!               cp1++;
!           *cp1 = '\0';
!           StrAllocCopy(anchor->charset, cp4);
!           HTPassEightBitRaw = TRUE;
!           HTAlert(anchor->charset);
        }
        FREE(cp3);
      } else if (cp1 != NULL) {
--- 933,976 ----
            }
        } else {
            /*
!           **  Cannot translate.
!           **  If according to some heuristic the given
!           **  charset and the current display character
!           **  both are likely to be like ISO-8859 in
!           **  structure, pretend we have some kind
!           **  of match.
            */
!           BOOL given_is_8859
!               = (!strncmp(cp4, "iso-8859-", 9) &&
!                  isdigit((unsigned char)cp4[9]));
!           BOOL given_is_8859like
!               = (given_is_8859 ||
!                  !strncmp(cp4, "windows-", 10) ||
!                  !strncmp(cp4, "cp12", 4) ||
!                  !strncmp(cp4, "cp-12", 5));
!           BOOL given_and_display_8859like
!               = (given_is_8859like &&
!                  (strstr(LYchar_set_names[current_char_set],
!                          "ISO-8859") ||
!                   strstr(LYchar_set_names[current_char_set],
!                          "windows-")));
! 
!           if (given_and_display_8859like) {
!               *cp1 = '\0';
!               format = HTAtom_for(cp);
!           }
!           if (given_is_8859) {
!               cp1 = &cp4[10];
!               while (*cp1 &&
!                      isdigit((unsigned char)(*cp1)))
!                   cp1++;
!               *cp1 = '\0';
!           }
!           if (given_and_display_8859like) {
!               StrAllocCopy(anchor->charset, cp4);
!               HTPassEightBitRaw = TRUE;
!           }
!           HTAlert(*cp4 ? cp4 : anchor->charset);
        }
        FREE(cp3);
      } else if (cp1 != NULL) {
*** lynx2-8-2.old/src/LYCharUtils.c     Sun Jan  3 05:36:28 1999
--- lynx2-8-2/src/LYCharUtils.c Sat Jan 16 01:34:20 1999
***************
*** 2826,2841 ****
                                 me->outUCLYhndl, me->outUCI);
            } else {
                /*
!                *  Hope it's a match, for now. - FM
                 */
!               cp1 = &cp4[10];
!               while (*cp1 &&
!                      isdigit((unsigned char)(*cp1)))
!                   cp1++;
!               *cp1 = '\0';
!               StrAllocCopy(me->node_anchor->charset, cp4);
!               HTPassEightBitRaw = TRUE;
!               HTAlert(me->node_anchor->charset);
  
            }
            FREE(cp3);
--- 2826,2864 ----
                                 me->outUCLYhndl, me->outUCI);
            } else {
                /*
!                *  Cannot translate.
!                *  If according to some heuristic the given
!                *  charset and the current display character
!                *  both are likely to be like ISO-8859 in
!                *  structure, pretend we have some kind
!                *  of match.
                 */
!               BOOL given_is_8859
!                   = (!strncmp(cp4, "iso-8859-", 9) &&
!                      isdigit((unsigned char)cp4[9]));
!               BOOL given_is_8859like
!                   = (given_is_8859 || !strncmp(cp4, "windows-", 10) ||
!                       !strncmp(cp4, "cp12", 4) ||
!                       !strncmp(cp4, "cp-12", 5));
!               BOOL given_and_display_8859like
!                   = (given_is_8859like &&
!                      (strstr(LYchar_set_names[current_char_set],
!                              "ISO-8859") ||
!                       strstr(LYchar_set_names[current_char_set],
!                              "windows-")));
! 
!               if (given_is_8859) {
!                   cp1 = &cp4[10];
!                   while (*cp1 &&
!                          isdigit((unsigned char)(*cp1)))
!                       cp1++;
!                   *cp1 = '\0';
!               }
!               if (given_and_display_8859like) {
!                   StrAllocCopy(me->node_anchor->charset, cp4);
!                   HTPassEightBitRaw = TRUE;
!               }
!               HTAlert(*cp4 ? cp4 : me->node_anchor->charset);
  
            }
            FREE(cp3);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]