|
From: Jeff R. <dv...@us...> - 2011-08-24 18:48:55
|
Update of /cvsroot/aolserver/aolserver/nsd
In directory vz-cvs-4.sog:/tmp/cvs-serv27790/nsd
Modified Files:
adpparse.c
Log Message:
nsd/adpparse.c: enhance parsing to recognize a xml-style minimized
registered tag as an empty open/close sequence. Fix to allow
arbitrary balanced nesting of <% %> tags (SF bug #2958550)
Index: adpparse.c
===================================================================
RCS file: /cvsroot/aolserver/aolserver/nsd/adpparse.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** adpparse.c 19 Jun 2006 15:01:41 -0000 1.21
--- adpparse.c 24 Aug 2011 18:48:53 -0000 1.22
***************
*** 62,65 ****
--- 62,66 ----
char *tag; /* The name of the tag (e.g., "mytag") */
char *endtag; /* The closing tag or null (e.g., "/mytag")*/
+ int balanced;/* true if open/close tags are the same */
char *string; /* Proc (e.g., "ns_adp_netscape") or ADP string. */
} Tag;
***************
*** 201,204 ****
--- 202,207 ----
Tcl_SetHashValue(hPtr, tagPtr);
tagPtr->tag = Tcl_GetHashKey(&servPtr->adp.tags, hPtr);
+ tagPtr->balanced=(tagPtr->endtag != NULL && *(tagPtr->endtag) == '/' &&
+ STREQ(tagPtr->tag, (tagPtr->endtag+1)));
Ns_RWLockUnlock(&servPtr->adp.taglock);
Tcl_DStringFree(&tbuf);
***************
*** 289,302 ****
*/
- level = 0;
e = strstr(e - 1, "%>");
n = s + 2;
while (e != NULL && (n = strstr(n, "<%")) != NULL && n < e) {
- ++level;
n = n + 2;
- }
- while (e != NULL && level > 0) {
e = strstr(e + 2, "%>");
- --level;
}
if (e == NULL) {
--- 292,300 ----
***************
*** 356,359 ****
--- 354,360 ----
AppendTag(&parse, tagPtr, a, e, NULL);
text = e + 1;
+ } else if (tagPtr->balanced && *(e-1) == '/') {
+ AppendTag(&parse, tagPtr, a, e, e+1);
+ text = e + 1;
} else {
as = a;
***************
*** 592,595 ****
--- 593,603 ----
*servPtr = 0;
}
+ /*
+ * discard a trailing '/' from the attribute value
+ * for xml-ish minimized empty elements
+ */
+ if (*(e-1) == '/') {
+ e--;
+ }
while (s < e) {
/*
|