[Redbutton-devel] SF.net SVN: redbutton: [9] redbutton-download/trunk/command.c
Brought to you by:
skilvington
|
From: <ski...@us...> - 2006-03-02 11:50:46
|
Revision: 9 Author: skilvington Date: 2006-03-02 03:50:43 -0800 (Thu, 02 Mar 2006) ViewCVS: http://svn.sourceforge.net/redbutton/?rev=9&view=rev Log Message: ----------- remove // and /./ in canonical ContentReferences Modified Paths: -------------- redbutton-download/trunk/command.c Modified: redbutton-download/trunk/command.c =================================================================== --- redbutton-download/trunk/command.c 2006-03-02 11:22:44 UTC (rev 8) +++ redbutton-download/trunk/command.c 2006-03-02 11:50:43 UTC (rev 9) @@ -287,15 +287,24 @@ /* no more slashes => nothing left to do */ if(*slash == '\0') return _canon; - /* if the next path component is "../", eat the previous one */ - if(strncmp(slash, "/../", 4) == 0) + /* if this component is empty (ie ./ or /) remove it */ + if(strncmp(start, "./", 2) == 0 || *start == '/') { /* include \0 terminator */ - len = strlen(start) + 1; - memmove(start, slash + 4, len - ((slash - start) + 4)); + len = strlen(slash + 1) + 1; + memmove(start, slash + 1, len); /* restart the search */ start = _canon; } + /* if the next path component is "../", eat this one */ + else if(strncmp(slash, "/../", 4) == 0) + { + /* include \0 terminator */ + len = strlen(slash + 4) + 1; + memmove(start, slash + 4, len); + /* restart the search */ + start = _canon; + } else { /* move to the next component */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |