----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
Daniel Veillard
Sent: 2008年3月26日 0:55
To: Ashwin
Cc: [email protected]; [EMAIL PROTECTED]
Subject: Re: [xml] Normalization Query

On Wed, Mar 19, 2008 at 10:15:15AM +0530, Ashwin wrote:
> The confusion is exarcebated by the fact that Java based parsers are doing
> Normalization which returns values which I have mentioned that are
contrary
> to what is being returned by libxml..
> 
>  
> 
> I do not know whether I am interpreting the spec wrongly, so any
> clarifications regarding the same would be extremely welcome.  
> 

>  No that was libxml2 bugs :-\ . They were a bit hard to fix, but hopefully
> they are fixed in SVN, could you please checkout and rerun your tests.
> I have tried to include your examples in the regression suite, and also
> fixed the over normalization issue you raised earlier.

>  I hope this is fine now,

Thanks for the fixes!!!

However there seems to be a slight problem in xmlAttrNormalizeSpace2...

When this function is called in xmlParseAttribute2..

val2 = xmlAttrNormalizeSpace2(ctxt, val, len);
if (val2 != NULL) {
   xmlFree(val);   // Here if only leading spaces are present              
val = val2;       //xmlAttrNormalizeSpace2 returns the pointer to the first

                    char after the leading spaces, so in this case val2
                    will point to the same memory as val except it will be

                    ahead by the number of whitespaces....

So freeing val will in effect free val2 as well, and thus will lead to
problems.

I am attaching a patch which takes care of the problem. Please let me know
if this is ok.

Regards
Ashwin 
   
*** parser.c    2008-04-18 12:55:26.000000000 +0530
--- parserfix.c 2008-04-18 13:03:30.000000000 +0530
*************** xmlAttrNormalizeSpace2(xmlParserCtxtPtr 
*** 919,924 ****
--- 919,925 ----
      int remove_head = 0;
      int need_realloc = 0;
      const xmlChar *cur;
+      xmlChar *ret;    
  
      if ((ctxt == NULL) || (src == NULL) || (len == NULL))
          return(NULL);
*************** xmlAttrNormalizeSpace2(xmlParserCtxtPtr 
*** 942,949 ****
            cur++;
      }
      if (need_realloc) {
-         xmlChar *ret;
- 
        ret = xmlStrndup(src + remove_head, i - remove_head + 1);
        if (ret == NULL) {
            xmlErrMemory(ctxt, NULL);
--- 943,948 ----
*************** xmlAttrNormalizeSpace2(xmlParserCtxtPtr 
*** 954,960 ****
          return(ret);
      } else if (remove_head) {
          *len -= remove_head;
!       return(src + remove_head);
      }
      return(NULL);
  }
--- 953,964 ----
          return(ret);
      } else if (remove_head) {
          *len -= remove_head;
!          ret = xmlStrndup(src + remove_head, *len);
!          if (ret == NULL) {
!           xmlErrMemory(ctxt, NULL);
!           return(NULL);
!          }
!          return(ret);
      }
      return(NULL);
  }
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to