Re: [xslt] was RE:[] forward and back slashes in URI



On Tue, Aug 14, 2001 at 03:01:31PM -0600, Vakoc, Mark wrote:
> xsltDocumentElem() builds a proper URI, so my input of:
> 
> file:///f:/debug test/file.xml  becomes
> file:///f%3A/debug%20test/file.xml
> 
> It then calls xsltSaveResultToFilename which calls
> xmlOutputBufferCreateFilename which then uses the matching output callback
> of xmlFileOpenW.
> 
> xmlFileOpenW (after applying my simple win32 fix mentioned earier) would
> pass
> f%3A/debug%20test/file.xml to fopen().
> 
> The reason document() worked is xmlParserInputBufferCreateFilename calls
> xmlURIUnescapeString(), however xmlOutputBufferCreateFilename() never calls
> xmlURIUnescapeString() before going through the output callbacks.

  Okay thanks for looking at the problem, can you check that the enclosed
patch fixes the problem ?

  thanks,

Daniel

-- 
Daniel Veillard      | Red Hat Network http://redhat.com/products/network/
veillard@redhat.com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
Index: xmlIO.c
===================================================================
RCS file: /cvs/gnome/gnome-xml/xmlIO.c,v
retrieving revision 1.55
diff -c -r1.55 xmlIO.c
*** xmlIO.c	2001/08/14 12:18:08	1.55
--- xmlIO.c	2001/08/14 22:59:46
***************
*** 1663,1670 ****
                                xmlCharEncodingHandlerPtr encoder,
  			      int compression) {
      xmlOutputBufferPtr ret;
!     int i;
      void *context = NULL;
  
      int is_http_uri = 0;	/*   Can't change if HTTP disabled  */
  
--- 1663,1671 ----
                                xmlCharEncodingHandlerPtr encoder,
  			      int compression) {
      xmlOutputBufferPtr ret;
!     int i = 0;
      void *context = NULL;
+     char *unescaped;
  
      int is_http_uri = 0;	/*   Can't change if HTTP disabled  */
  
***************
*** 1679,1718 ****
      is_http_uri = xmlIOHTTPMatch( URI );
  #endif
  
  #ifdef HAVE_ZLIB_H
!     if ((compression > 0) && (compression <= 9) && (is_http_uri == 0)) {
!         context = xmlGzfileOpenW(URI, compression);
! 	if (context != NULL) {
! 	    ret = xmlAllocOutputBuffer(encoder);
! 	    if (ret != NULL) {
! 		ret->context = context;
! 		ret->writecallback = xmlGzfileWrite;
! 		ret->closecallback = xmlGzfileClose;
  	    }
- 	    return(ret);
  	}
-     }
  #endif
  
      /*
!      * Try to find one of the output accept method accepting that scheme
!      * Go in reverse to give precedence to user defined handlers.
       */
!     for (i = xmlOutputCallbackNr - 1;i >= 0;i--) {
! 	if ((xmlOutputCallbackTable[i].matchcallback != NULL) &&
! 	    (xmlOutputCallbackTable[i].matchcallback(URI) != 0)) {
! 
! #if ( defined( LIBXML_HTTP_ENABLED ) && defined( HAVE_ZLIB_H ) )
! 	    /*  Need to pass compression parameter into HTTP open calls  */
! 
! 	    if ( xmlOutputCallbackTable[i].matchcallback == xmlIOHTTPMatch )
! 		context = xmlIOHTTPOpenW( URI, compression );
! 	    else
  #endif
  		context = xmlOutputCallbackTable[i].opencallback(URI);
! 
! 	    if (context != NULL)
! 		break;
  	}
      }
  
--- 1680,1758 ----
      is_http_uri = xmlIOHTTPMatch( URI );
  #endif
  
+ 
+     /*
+      * Try to find one of the output accept method accepting taht scheme
+      * Go in reverse to give precedence to user defined handlers.
+      * try with an unescaped version of the URI
+      */
+     unescaped = xmlURIUnescapeString(URI, 0, NULL);
+     if (unescaped != NULL) {
  #ifdef HAVE_ZLIB_H
! 	if ((compression > 0) && (compression <= 9) && (is_http_uri == 0)) {
! 	    context = xmlGzfileOpenW(unescaped, compression);
! 	    if (context != NULL) {
! 		ret = xmlAllocOutputBuffer(encoder);
! 		if (ret != NULL) {
! 		    ret->context = context;
! 		    ret->writecallback = xmlGzfileWrite;
! 		    ret->closecallback = xmlGzfileClose;
! 		}
! 		xmlFree(unescaped);
! 		return(ret);
  	    }
  	}
  #endif
+ 	for (i = xmlOutputCallbackNr - 1;i >= 0;i--) {
+ 	    if ((xmlOutputCallbackTable[i].matchcallback != NULL) &&
+ 		(xmlOutputCallbackTable[i].matchcallback(unescaped) != 0)) {
+ #if defined(LIBXML_HTTP_ENABLED) && defined(HAVE_ZLIB_H)
+ 		/*  Need to pass compression parameter into HTTP open calls  */
+ 		if (xmlOutputCallbackTable[i].matchcallback == xmlIOHTTPMatch)
+ 		    context = xmlIOHTTPOpenW(unescaped, compression);
+ 		else
+ #endif
+ 		    context = xmlOutputCallbackTable[i].opencallback(unescaped);
+ 		if (context != NULL)
+ 		    break;
+ 	    }
+ 	}
+ 	xmlFree(unescaped);
+     }
  
      /*
!      * If this failed try with a non-escaped URI this may be a strange
!      * filename
       */
!     if (context == NULL) {
! #ifdef HAVE_ZLIB_H
! 	if ((compression > 0) && (compression <= 9) && (is_http_uri == 0)) {
! 	    context = xmlGzfileOpenW(URI, compression);
! 	    if (context != NULL) {
! 		ret = xmlAllocOutputBuffer(encoder);
! 		if (ret != NULL) {
! 		    ret->context = context;
! 		    ret->writecallback = xmlGzfileWrite;
! 		    ret->closecallback = xmlGzfileClose;
! 		}
! 		return(ret);
! 	    }
! 	}
  #endif
+ 	for (i = xmlOutputCallbackNr - 1;i >= 0;i--) {
+ 	    if ((xmlOutputCallbackTable[i].matchcallback != NULL) &&
+ 		(xmlOutputCallbackTable[i].matchcallback(URI) != 0)) {
  		context = xmlOutputCallbackTable[i].opencallback(URI);
! #if defined(LIBXML_HTTP_ENABLED) && defined(HAVE_ZLIB_H)
! 		/*  Need to pass compression parameter into HTTP open calls  */
! 		if (xmlOutputCallbackTable[i].matchcallback == xmlIOHTTPMatch)
! 		    context = xmlIOHTTPOpenW(URI, compression);
! 		else
! #endif
! 		    context = xmlOutputCallbackTable[i].opencallback(URI);
! 		if (context != NULL)
! 		    break;
! 	    }
  	}
      }
  


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