lynx-dev
[Top][All Lists]
Advanced

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

LYNX-DEV RE: error recovery for formparsing -- BETTER SOLUTION


From: Laura Eaves
Subject: LYNX-DEV RE: error recovery for formparsing -- BETTER SOLUTION
Date: Sat, 5 Apr 1997 13:12:15 -0500 (EST)

Hi -- I was experimenting with the fix I sent the other day and noticed that
even with the fix (which corrected the problem with forms), a trace of the
rendering of these pages was still rather rocky -- lots of poor error recovery
for tags out of place.

I decided to take another approach.  The change is still small and local to
SGML.c, but changes the way parsing errors are handled in general.  Of course,
this is more "dangerous" than the first fix, since it affects more types of
elements.  But I've been running it on a number of pages and it seems to work
fine -- fixing problems with bad html -- and of course it doesn't affect pages
that have correct html.

Strategy of fix:  If and end tag </xxx> is found that doesn't match the top
element of the stack, search down the stack until you find a match.  If
there's no match, ignore the end tag; otherwise move the matching element to
the top of the stack and proceed.

I would really like to hear your thoughts on whether you think
this fix is a good idea.  Is there a reason not to do it this way?
So far I haven't seen a website that suffers from the fix...
I've also given it to some friends to test...

I made the original fix in lynx2.7-0.38, but also
incorporated it into lynx2-7-1.

Note: if you reply to this email, please copy me.  I subscribed
to lynx-dev last Monday, but for some reason I haven't gotten
any mail.  I sent a "who" command to majordomo and I'm definitely
subscribed, but for some reason the mail isn't getting to me.

Thanks!

Fix included below.
Comments welcome.
--le

*** old/SGML.c  Thu Apr  3 07:31:36 1997
--- WWW/Library/Implementation/SGML.c   Sat Apr  5 11:12:21 1997
***************
*** 521,561 ****
                            old_tag->name);
        return;
      }
! #ifdef WIND_DOWN_STACK
!     while (context->element_stack) { /* Loop is error path only */
! #else
      if (context->element_stack) { /* Substitute and remove one stack element 
*/ 
- #endif /* WIND_DOWN_STACK */
        HTElement * N = context->element_stack;
        HTTag * t = N->tag;
        
        if (old_tag != t) {             /* Mismatch: syntax error */
!           if (context->element_stack->next) { /* This is not the last level */
!               if (TRACE) fprintf(stderr,
!               "SGML: Found </%s> when expecting </%s>. </%s> assumed.\n",
!                   old_tag->name, t->name, t->name);
!           } else {                    /* last level */
!               if (TRACE) fprintf(stderr,
!                   "SGML: Found </%s> when expecting </%s>. </%s> Ignored.\n",
!                   old_tag->name, t->name, old_tag->name);
!               return;                 /* Ignore */
            }
!           
        }
        
        context->element_stack = N->next;               /* Remove from stack */
        FREE(N);
        (*context->actions->end_element)(context->target,
                 t - context->dtd->tags, (char **)&context->include);
- #ifdef WIND_DOWN_STACK
-       if (old_tag == t)
-           return;  /* Correct sequence */
- #else
        return;
- #endif /* WIND_DOWN_STACK */
-       
-       /* Syntax error path only */
-       
      }
      if (TRACE)
          fprintf(stderr, "SGML: Extra end tag </%s> found and ignored.\n",
--- 521,566 ----
                            old_tag->name);
        return;
      }
! again:
      if (context->element_stack) { /* Substitute and remove one stack element 
*/ 
        HTElement * N = context->element_stack;
        HTTag * t = N->tag;
        
        if (old_tag != t) {             /* Mismatch: syntax error */
!           HTElement *l, *p;
!           if (TRACE)
!               fprintf(stderr,
!               "SGML: Found </%s> when expecting </%s>. Searching stack.\n",
!                   old_tag->name, t->name);
!           for ( l=N,p=N->next; p; l=p,p=p->next ) {
!               if (TRACE)
!                   fprintf(stderr,"   Fount <%s>...\n",p->tag->name);
!               if ( old_tag == p->tag ) break;
            }
!           if ( p == 0 ) {
!               if ( TRACE )
!                   fprintf(stderr,
!                       "SGML: <%s> not found on stack. </%s> ignored.\n",
!                       old_tag->name, old_tag->name);
!               return;
!           }
!           if (TRACE)
!               fprintf(stderr,
!                   "SGML: <%s> found on stack. Moving <%s> to top of stack.\n",
!                   old_tag->name, old_tag->name);
!           l->next = p->next; /* delete p from stack */
!           p->next = N; /* put p at top of stack */
!           N = context->element_stack = p;
!           t = N->tag;
        }
        
        context->element_stack = N->next;               /* Remove from stack */
        FREE(N);
+       if (TRACE)
+           fprintf(stderr,"SGML: Popped <%s> from stack.\n",t->name);
        (*context->actions->end_element)(context->target,
                 t - context->dtd->tags, (char **)&context->include);
        return;
      }
      if (TRACE)
          fprintf(stderr, "SGML: Extra end tag </%s> found and ignored.\n",
;
; To UNSUBSCRIBE:  Send a mail message to address@hidden
;                  with "unsubscribe lynx-dev" (without the
;                  quotation marks) on a line by itself.
;

reply via email to

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