[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-wget] [PATCH 15/25] Bugfix: Process Metalink/XML url strings co
From: |
Giuseppe Scrivano |
Subject: |
Re: [Bug-wget] [PATCH 15/25] Bugfix: Process Metalink/XML url strings containing white spaces and CRLF |
Date: |
Sun, 11 Sep 2016 23:03:18 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) |
Matthew White <address@hidden> writes:
> +void
> +clean_metalink_string (char **str)
> +{
> + int c;
> + size_t len;
> + char *new, *beg, *end;
> +
> + if (!str || !*str)
> + return;
> +
> + beg = *str;
> +
> + while ((c = *beg) && (c == '\n' || c == '\r' || c == '\t' || c == ' '))
> + beg++;
> +
> + end = beg;
> +
> + /* To not truncate a string containing spaces, search the first '\r'
> + or '\n' which ipotetically marks the end of the string. */
> + while ((c = *end) && (c != '\r') && (c != '\n'))
> + end++;
> +
> + /* If we are at the end of the string, search the first legit
> + character going backward. */
> + if (*end == '\0')
> + while ((c = *(end - 1)) && (c == '\n' || c == '\r' || c == '\t' || c ==
> ' '))
> + end--;
> +
> + len = end - beg;
> +
> + new = xmemdup0 (beg, len);
ACK
Giuseppe