[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
httpfs ChangeLog extract.c
From: |
Samuel Thibault |
Subject: |
httpfs ChangeLog extract.c |
Date: |
Sun, 27 Jan 2013 23:16:14 +0000 |
CVSROOT: /cvsroot/hurdextras
Module name: httpfs
Changes by: Samuel Thibault <sthibaul> 13/01/27 23:16:14
Modified files:
. : ChangeLog extract.c
Log message:
* extract.c (extract): Use strdupa for temporary strings. Ignore
absolute URLs. Drop internal refs and form data instead of
ignoring
the whole link. Stop trying to resolve directory names.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/httpfs/ChangeLog?cvsroot=hurdextras&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/httpfs/extract.c?cvsroot=hurdextras&r1=1.1.1.1&r2=1.2
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/hurdextras/httpfs/ChangeLog,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- ChangeLog 27 Jan 2013 23:14:22 -0000 1.9
+++ ChangeLog 27 Jan 2013 23:16:14 -0000 1.10
@@ -1,6 +1,9 @@
2013-01-28 Samuel Thibault <address@hidden>
* parsehtml.c (startElement): Use strcasecmp to match "href".
+ * extract.c (extract): Use strdupa for temporary strings. Ignore
+ absolute URLs. Drop internal refs and form data instead of ignoring
+ the whole link. Stop trying to resolve directory names.
2013-01-25 Samuel Thibault <address@hidden>
Index: extract.c
===================================================================
RCS file: /cvsroot/hurdextras/httpfs/extract.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- extract.c 15 Apr 2002 19:25:41 -0000 1.1.1.1
+++ extract.c 27 Jan 2013 23:16:14 -0000 1.2
@@ -58,12 +58,12 @@
}
-void extract(char *string,char *parent)
+void extract(char *_string,char *parent)
{
/* This function extracts file/directory info from string and fills
* into the intermediate data structure *files */
- int check_url=0,unfilled_dir=0;
+ int unfilled_dir=0;
int i=0;
const char delimiters[]="/";
char *temp;
@@ -71,26 +71,42 @@
char *token;
char *name;
int no_of_slashes_here=0;
+ char *string = strdupa(_string);
/* string can be a directory, file, url or path to a file */
- if ( ! (strcmp((const char*)strndup(string,7),"http://")) )
+ if ( ! (strncasecmp(string,"http://", 7)) )
{
+ /* Ignore absolute URLs */
+#if 0
/* URL */
string = string + 7;
if ( check_dups(string,parent) )
fill_files(string,parent,0,HTTP_URL);
+#endif
return;
}
- if( strchr(string,'#') != NULL || strchr(string,'?') != NULL ||
string[0] == '.' )
+
+ /* Drop internal link */
+ token = strchr(string, '#');
+ if (token)
+ *token = 0;
+ /* Drop GET form data */
+ token = strchr(string, '?');
+ if (token)
+ *token = 0;
+
+ if( string[0] == '.' && string[1] == '/')
{
- /* # internal link leave it */
- return;
+ /* Skip leading ./// */
+ string++;
+ while (string[0] == '/')
+ string++;
}
if(string[0]=='/')
{
/* it is a path starting from root directory */
- temp = strdup(string);
+ temp = strdupa(string);
while ( strchr(temp,'/') != NULL )
{
@@ -120,7 +136,7 @@
return;
}
- token = strdup(string);
+ token = strdupa(string);
for ( i=0 ; i<no_of_slashes-1 ; i++ )
{
/* extract file and directory from the string
@@ -129,15 +145,14 @@
* extract temp fill it as a directory under file/
* extract a.html fill it as a file under temp/ */
- temp = strdup(token);
+ temp = strdupa(token);
if ( strcmp(dir_tok[i],strtok(temp,"/")) )
return;
strcpy(token,strchr(token,'/'));
token++;
}
- parent = strdup("tmp");
- string = strdup(token);
- check_url=1;
+ parent = strdupa("tmp");
+ string = strdupa(token);
}
if( string[strlen(string)-1]=='/' )
@@ -146,23 +161,12 @@
* to be filled on demand make a note that its unfilled directory */
unfilled_dir = 1;
}
- token=strdup(string);
+ token=strdupa(string);
while(strchr(token,'/')!=NULL)
{
/* Handles Directories */
- temp=strdup(token);
+ temp=strdupa(token);
name=strtok(temp,delimiters);
- if ( check_url == 0 ) {
- if(((x=gethostbyname(name))!=NULL))
- {
- /* Check if its an URL */
- unfilled_dir = 0;
- if ( check_dups(string,parent) )
- fill_files(name,parent,0,HTTP_URL);
- return;
- }
- check_url=1;
- }
strcpy(token,strchr(token,'/'));
token=token+sizeof(char);
@@ -172,7 +176,7 @@
if ( unfilled_dir )
this_entry->f_type = HTTP_DIR_NOT_FILLED;
}
- parent=strdup(name);
+ parent=strdupa(name);
}
if(strlen(token)>0)
@@ -183,16 +187,6 @@
* Also Handle if there is no slash at all -- just file name
* or it can be a url */
name=strtok(token,delimiters);
- if ( check_url == 0 )
- {
- if(((x=gethostbyname(name))!=NULL))
- {
- /* It can be a URL check and return */
- if ( check_dups(string,parent) )
- fill_files(name,parent,0,HTTP_URL);
- return;
- }
- }
if ( check_dups(name,parent) )
fill_files(name,parent,0,HTTP_FILE);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- httpfs ChangeLog extract.c,
Samuel Thibault <=