[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-wget] [PATCH 16/25] Bugfix: Remove surrounding quotes from Meta
From: |
Giuseppe Scrivano |
Subject: |
Re: [Bug-wget] [PATCH 16/25] Bugfix: Remove surrounding quotes from Metalink/HTTP key's value |
Date: |
Sun, 11 Sep 2016 23:10:55 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) |
Matthew White <address@hidden> writes:
> +/*
> + Remove the quotation surrounding a string.
> +
> + The string is permanently modified.
> + */
> +void
> +dequote_metalink_string (char **str)
> +{
> + char *new, *beg, *end;
> + size_t str_len, new_len;
> +
> + if (!str || !*str)
> + return;
> +
> + str_len = strlen (*str); /* current string length */
> +
> + if (str_len < 2)
> + return;
> +
> + new_len = str_len - 2; /* predict dequoted length */
> +
> + beg = *str; /* begin of current string */
> + end = *str + (str_len - 1); /* end of current string */
> +
> + /* Verify if the current string is surrounded by quotes. */
> + if (!(*beg == '\"' && *end == '\"') && !(*beg == '\'' && *end == '\''))
> + return;
could we just verify that (*str[0] == '\"' || *str[0] == '\'') and in
case return before computing the strlen?
Giuseppe