Nmap Development mailing list archives
Re: Path to nmap.xsl for win32
From: jah <jah () zadkiel plus com>
Date: Thu, 25 Sep 2008 03:12:56 +0100
On 24/09/2008 21:31, David Fifield wrote:
On Wed, Sep 24, 2008 at 08:58:02PM +0100, jah wrote:On 24/09/2008 20:22, David Fifield wrote:Does anybody know, is it more correct to put "file://" in front of the XSL stylesheet location when it points to a local file (as it does in the default case)?I don't know if it's more correct, but I notice that the nmap xml output can be viewed in firefox if file:// is used.On Windows you mean? Opening Nmap XML in Firefox works for me on GNU/Linux.Usually, I'll open these files in Internet Explorer or a proper xml viewer because they don't display in firefox - maybe the lack of file:// is the reason?I wouldn't be surprised. I think a string like C:\Program Files\Nmap\nmap.xsl is not a URI. If changing it to file://C:\Program Files\Nmap\nmap.xsl makes it work in Firefox on Windows, I say we should do it. I have a feeling that it should even be file://C:/Program Files/Nmap/nmap.xsl but I won't commit to that until I read some documentation that says that's right.
According to [1] it should be file:///C:/Program Files/Nmap/nmap.xsl "In general, a file path is converted to a URI by adding the scheme identifier file:, then three forward slashes (representing an empty authority or host segment), then the path with all backslashes converted to forward slashes. " One thing I found is that if nmap_fetchfile fails on win32 then both firefox and IE will display the xml file if the stylesheet is in the same directory as long as file:/// is not prepended to the stylesheet filename. However, if file:/// is prepended and the stylesheet is in the root of the current drive, IE will display the xml, but Firefox will not. I've attached a patch which belies my rudimentary C/C++, but does the trick. If fetchfile fails on windows then file:/// is not prepended to the filename. In the section entitled UNC Paths [1] it says the URI should be file://///servername/share/file.ext which might be a nice addition to --stylesheet Regards, jah [1] http://kb.mozillazine.org/Firefox_:_Issues_:_Links_to_Local_Pages_Don%27t_Work#Path_Syntax
--- NmapOps.cc.orig 2008-09-25 02:47:43.570243100 +0100 +++ NmapOps.cc 2008-09-25 02:48:54.179618100 +0100 @@ -177,6 +177,7 @@ void NmapOps::Initialize() { char tmpxsl[MAXPATHLEN]; + char tmpfxsl[sizeof(tmpxsl)+16]; setaf(AF_INET); #if defined WIN32 || defined __amigaos__ @@ -254,8 +255,20 @@ Snprintf(tmpxsl, sizeof(tmpxsl), "%s/nmap.xsl", NMAPDATADIR); #endif } + Strncpy(tmpfxsl, "file:///", sizeof(tmpfxsl)); + for (char* p = tmpxsl; *p; ++p) { + if (*p == '\\') *p = '/'; + } + while(*tmpxsl == '/') + memmove(tmpxsl, tmpxsl+1, sizeof(tmpxsl)); // trim leading slashes so we have file:/// +#if WIN32 + if (!strcmp(tmpxsl, "nmap.xsl")) { + Strncpy(tmpfxsl, "", sizeof(tmpfxsl)); // filename only if fetchfile failed for win32 + } +#endif + strcat( tmpfxsl, tmpxsl ); if (xsl_stylesheet) free(xsl_stylesheet); - xsl_stylesheet = strdup(tmpxsl); + xsl_stylesheet = strdup(tmpfxsl); spoof_mac_set = false; mass_dns = true; log_errors = false;
_______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- Path to nmap.xsl for win32 jah (Sep 13)
- Re: Path to nmap.xsl for win32 David Fifield (Sep 23)
- Re: Path to nmap.xsl for win32 jah (Sep 24)
- Re: Path to nmap.xsl for win32 David Fifield (Sep 24)
- Re: Path to nmap.xsl for win32 jah (Sep 24)
- Re: Path to nmap.xsl for win32 David Fifield (Sep 24)
- Re: Path to nmap.xsl for win32 jah (Sep 24)
- Re: Path to nmap.xsl for win32 David Fifield (Sep 29)
- Re: Path to nmap.xsl for win32 jah (Sep 29)
- Re: Path to nmap.xsl for win32 David Fifield (Sep 29)
- Re: Path to nmap.xsl for win32 jah (Sep 29)
- Re: Path to nmap.xsl for win32 jah (Sep 24)
- Re: Path to nmap.xsl for win32 David Fifield (Sep 23)