You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by yl...@apache.org on 2020/06/22 10:30:21 UTC
svn commit: r1879075 - /httpd/httpd/trunk/server/util.c
Author: ylavic
Date: Mon Jun 22 10:30:20 2020
New Revision: 1879075
URL: http://svn.apache.org/viewvc?rev=1879075&view=rev
Log:
Implement ap_getparent() using ap_normalize_path().
It is functionaly the same as AP_NORMALIZE_ALLOW_RELATIVE flag, while
ap_normalize_path() is more efficient (single pass).
Modified:
httpd/httpd/trunk/server/util.c
Modified: httpd/httpd/trunk/server/util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util.c?rev=1879075&r1=1879074&r2=1879075&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util.c (original)
+++ httpd/httpd/trunk/server/util.c Mon Jun 22 10:30:20 2020
@@ -607,70 +607,9 @@ AP_DECLARE(int) ap_normalize_path(char *
*/
AP_DECLARE(void) ap_getparents(char *name)
{
- char *next;
- int l, w, first_dot;
-
- /* Four paseses, as per RFC 1808 */
- /* a) remove ./ path segments */
- for (next = name; *next && (*next != '.'); next++) {
- }
-
- l = w = first_dot = next - name;
- while (name[l] != '\0') {
- if (name[l] == '.' && IS_SLASH(name[l + 1])
- && (l == 0 || IS_SLASH(name[l - 1])))
- l += 2;
- else
- name[w++] = name[l++];
- }
-
- /* b) remove trailing . path, segment */
- if (w == 1 && name[0] == '.')
- w--;
- else if (w > 1 && name[w - 1] == '.' && IS_SLASH(name[w - 2]))
- w--;
- name[w] = '\0';
-
- /* c) remove all xx/../ segments. (including leading ../ and /../) */
- l = first_dot;
-
- while (name[l] != '\0') {
- if (name[l] == '.' && name[l + 1] == '.' && IS_SLASH(name[l + 2])
- && (l == 0 || IS_SLASH(name[l - 1]))) {
- int m = l + 3, n;
-
- l = l - 2;
- if (l >= 0) {
- while (l >= 0 && !IS_SLASH(name[l]))
- l--;
- l++;
- }
- else
- l = 0;
- n = l;
- while ((name[n] = name[m]))
- (++n, ++m);
- }
- else
- ++l;
- }
-
- /* d) remove trailing xx/.. segment. */
- if (l == 2 && name[0] == '.' && name[1] == '.')
- name[0] = '\0';
- else if (l > 2 && name[l - 1] == '.' && name[l - 2] == '.'
- && IS_SLASH(name[l - 3])) {
- l = l - 4;
- if (l >= 0) {
- while (l >= 0 && !IS_SLASH(name[l]))
- l--;
- l++;
- }
- else
- l = 0;
- name[l] = '\0';
- }
+ (void)ap_normalize_path(name, AP_NORMALIZE_ALLOW_RELATIVE);
}
+
AP_DECLARE(void) ap_no2slash_ex(char *name, int is_fs_path)
{