diff options
-rw-r--r-- | CHANGES | 7 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTAccess.c | 7 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTAnchor.c | 115 | ||||
-rw-r--r-- | src/GridText.c | 18 |
4 files changed, 93 insertions, 54 deletions
diff --git a/CHANGES b/CHANGES index 3655848c..382c9ff8 100644 --- a/CHANGES +++ b/CHANGES @@ -1,9 +1,12 @@ --- $LynxId: CHANGES,v 1.564 2012/01/31 10:35:41 tom Exp $ +-- $LynxId: CHANGES,v 1.565 2012/02/03 01:47:08 tom Exp $ =============================================================================== Changes since Lynx 2.8 release =============================================================================== -2012-01-31 (2.8.8dev.10) +2012-02-02 (2.8.8dev.10) +* modify HTLoad() to discard charset information before reloading a document, + in case the server changes the content-type information between loads + (report by Stanislav Brabec) -TD * use tidy to indent html documentation -TD * provide a way to substitute parameters in URLs for jumpfiles (adapted from patch by Mark Skilbeck -TD diff --git a/WWW/Library/Implementation/HTAccess.c b/WWW/Library/Implementation/HTAccess.c index 63b4a04a..7587aa49 100644 --- a/WWW/Library/Implementation/HTAccess.c +++ b/WWW/Library/Implementation/HTAccess.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTAccess.c,v 1.74 2011/05/24 09:35:29 tom Exp $ + * $LynxId: HTAccess.c,v 1.75 2012/02/03 01:43:58 tom Exp $ * * Access Manager HTAccess.c * ============== @@ -687,6 +687,11 @@ static int HTLoad(const char *addr, HTProtocol *p; int status = get_physical(addr, anchor); + if (reloading) { + FREE(anchor->charset); + FREE(anchor->UCStages); + } + if (status == HT_FORBIDDEN) { /* prevent crash if telnet or similar was forbidden by rule. - kw */ LYFixCursesOn("show alert:"); diff --git a/WWW/Library/Implementation/HTAnchor.c b/WWW/Library/Implementation/HTAnchor.c index 2fc514c7..a3ebaeb7 100644 --- a/WWW/Library/Implementation/HTAnchor.c +++ b/WWW/Library/Implementation/HTAnchor.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTAnchor.c,v 1.70 2011/06/06 08:25:33 tom Exp $ + * $LynxId: HTAnchor.c,v 1.71 2012/02/03 01:52:50 tom Exp $ * * Hypertext "Anchor" Object HTAnchor.c * ========================== @@ -1234,6 +1234,29 @@ void HTAnchor_setPhysical(HTParentAnchor *me, } } +#ifdef DEBUG +static void show_stages(HTParentAnchor *me, const char *tag, int which_stage) +{ + int j; + + CTRACE((tfp, "Stages %s*%s", NonNull(me->charset), tag)); + for (j = 0; j < UCT_STAGEMAX; j++) { + CTRACE((tfp, " ")); + if (j == which_stage) + CTRACE((tfp, "(")); + CTRACE((tfp, "%d:%d:%s", + j, + me->UCStages->s[j].LYhndl, + NonNull(me->UCStages->s[j].C.MIMEname))); + if (j == which_stage) + CTRACE((tfp, ")")); + } + CTRACE((tfp, "\n")); +} +#else +#define show_stages(me,tag,which_stage) /* nothing */ +#endif + /* * We store charset info in the HTParentAnchor object, for several * "stages". (See UCDefs.h) @@ -1261,42 +1284,45 @@ void HTAnchor_setPhysical(HTParentAnchor *me, LYUCcharset *HTAnchor_getUCInfoStage(HTParentAnchor *me, int which_stage) { - if (me && !me->UCStages) { - int i; - int chndl = UCLYhndl_for_unspec; /* always >= 0 */ - UCAnchorInfo *stages = typecalloc(UCAnchorInfo); + LYUCcharset *result = NULL; - if (stages == NULL) - outofmem(__FILE__, "HTAnchor_getUCInfoStage"); + if (me) { + if (!me->UCStages) { + int i; + int chndl = UCLYhndl_for_unspec; /* always >= 0 */ + UCAnchorInfo *stages = typecalloc(UCAnchorInfo); - assert(stages != NULL); + if (stages == NULL) + outofmem(__FILE__, "HTAnchor_getUCInfoStage"); - for (i = 0; i < UCT_STAGEMAX; i++) { - stages->s[i].C.MIMEname = ""; - stages->s[i].LYhndl = -1; - } - if (me->charset) { - chndl = UCGetLYhndl_byMIME(me->charset); - if (chndl < 0) - chndl = UCLYhndl_for_unrec; - if (chndl < 0) - /* - * UCLYhndl_for_unrec not defined :-( - * fallback to UCLYhndl_for_unspec which always valid. - */ - chndl = UCLYhndl_for_unspec; /* always >= 0 */ - } - MemCpy(&stages->s[UCT_STAGE_MIME].C, &LYCharSet_UC[chndl], - sizeof(LYUCcharset)); + assert(stages != NULL); - stages->s[UCT_STAGE_MIME].lock = UCT_SETBY_DEFAULT; - stages->s[UCT_STAGE_MIME].LYhndl = chndl; - me->UCStages = stages; - } - if (me) { - return (&me->UCStages->s[which_stage].C); + for (i = 0; i < UCT_STAGEMAX; i++) { + stages->s[i].C.MIMEname = ""; + stages->s[i].LYhndl = -1; + } + if (me->charset) { + chndl = UCGetLYhndl_byMIME(me->charset); + if (chndl < 0) + chndl = UCLYhndl_for_unrec; + if (chndl < 0) + /* + * UCLYhndl_for_unrec not defined :-( + * fallback to UCLYhndl_for_unspec which always valid. + */ + chndl = UCLYhndl_for_unspec; /* always >= 0 */ + } + MemCpy(&stages->s[UCT_STAGE_MIME].C, &LYCharSet_UC[chndl], + sizeof(LYUCcharset)); + + stages->s[UCT_STAGE_MIME].lock = UCT_SETBY_DEFAULT; + stages->s[UCT_STAGE_MIME].LYhndl = chndl; + me->UCStages = stages; + } + result = (&me->UCStages->s[which_stage].C); + show_stages(me, "_getUCInfoStage", which_stage); } - return (NULL); + return (result); } int HTAnchor_getUCLYhndl(HTParentAnchor *me, @@ -1362,6 +1388,7 @@ LYUCcharset *HTAnchor_setUCInfoStage(HTParentAnchor *me, } else { p->UChndl = -1; } + show_stages(me, "_setUCInfoStage", which_stage); return (p); } } @@ -1373,21 +1400,25 @@ LYUCcharset *HTAnchor_resetUCInfoStage(HTParentAnchor *me, int which_stage, int set_by) { + LYUCcharset *result = NULL; int ohandle; - if (!me || !me->UCStages) - return (NULL); - me->UCStages->s[which_stage].lock = set_by; - ohandle = me->UCStages->s[which_stage].LYhndl; - me->UCStages->s[which_stage].LYhndl = LYhndl; + if (me && me->UCStages) { + me->UCStages->s[which_stage].lock = set_by; + ohandle = me->UCStages->s[which_stage].LYhndl; + me->UCStages->s[which_stage].LYhndl = LYhndl; #ifdef CAN_SWITCH_DISPLAY_CHARSET - /* Allow a switch to a more suitable display charset */ - if (LYhndl >= 0 && LYhndl != ohandle && which_stage == UCT_STAGE_PARSER) - setup_switch_display_charset(me, LYhndl); + /* Allow a switch to a more suitable display charset */ + if (LYhndl >= 0 && LYhndl != ohandle + && which_stage == UCT_STAGE_PARSER) + setup_switch_display_charset(me, LYhndl); #else - (void) ohandle; + (void) ohandle; #endif - return (&me->UCStages->s[which_stage].C); + show_stages(me, "_resetUCInfoStage", which_stage); + result = (&me->UCStages->s[which_stage].C); + } + return result; } /* diff --git a/src/GridText.c b/src/GridText.c index 96714b8d..1e381bc7 100644 --- a/src/GridText.c +++ b/src/GridText.c @@ -1,5 +1,5 @@ /* - * $LynxId: GridText.c,v 1.217 2011/12/27 01:52:36 tom Exp $ + * $LynxId: GridText.c,v 1.218 2012/02/03 01:27:52 tom Exp $ * * Character grid hypertext object * =============================== @@ -9055,13 +9055,14 @@ BOOLEAN HTLoadedDocumentIsSafe(void) const char *HTLoadedDocumentCharset(void) { - if (!HTMainText) - return (NULL); + const char *result = NULL; - if (HTMainText->node_anchor && HTMainText->node_anchor->charset) - return (HTMainText->node_anchor->charset); - else - return (NULL); + if (HTMainText && + HTMainText->node_anchor) { + result = HTMainText->node_anchor->charset; + } + + return result; } BOOL HTLoadedDocumentEightbit(void) @@ -11029,8 +11030,7 @@ int HText_SubmitForm(FormInfo * submit_item, DocInfo *doc, char *link_name, } if (target_cs < 0 && - HTMainText->node_anchor->charset && - *HTMainText->node_anchor->charset) { + non_empty(HTMainText->node_anchor->charset)) { target_cs = UCGetLYhndl_byMIME(HTMainText->node_anchor->charset); if (target_cs >= 0) { target_csname = HTMainText->node_anchor->charset; |