[FFmpeg-devel] [PATCH] Handling special characters in a URL.

Senthilnathan Maadasamy senthilnathan.maadasamy at gmail.com
Tue Feb 26 03:37:46 CET 2013


On Sat, Feb 23, 2013 at 12:14 AM, Stefano Sabatini <stefasab at gmail.com>wrote:

> > + * @param src portion of an URL (e.g. protocol, hostname, path) to
> > + *            percent-encoded
>
> percent-encode
>
Fixed.

>
> > +static size_t ff_url_percent_encode(char *dst, const char *src,
> > +                                    const char *allowed, size_t
> dst_size)
>
> note: since this is *static*, the ff_ is not even required, you can
> name it "percent_encode_url()" for example
>
Fixed.

>
> > +
>
> > +    if (enc_len < dst_size) dst[enc_len] = '\0';
>
> This should always terminate the buffer, even when the buffer is not
> long enough (but see comment below).
>
Fixed.

>
> > +
> > +    enc_size = ff_url_percent_encode(path_enc, path, "/?", path_size);
> > +    if (enc_size <= path_size) {
> > +        av_strlcpy(path, path_enc, path_size);
> > +    } else {
> > +        av_log(NULL, AV_LOG_ERROR,
> > +            "Skipping path percent-encoding since buffer is too
> small\n");
> > +    }
>
> I'm sorry to swing back and forth, since this is basically a custom
> function (no use outside this file), it might be better to implement
> your first approach, in order to avoid duplication and keep it simple
> (that is you do in-place encoding).
>
> Also the warning may be a bit more descriptive, for example:
>
>        av_log(NULL, AV_LOG_ERROR,
>               "Skipping percent-encoding for string '%s' since buffer is
> too small\n", );
>
>
I agree that this will make the code compact.  I have made the suggested
changes.  Please let me know if I have missed something.


> Then as I wrote av_url_split() suffers major problems (no way to
> signal errors, e.g. in case of buffer truncation), but fixing it is
> beyond the scope of this patch I guess.
>
> BTW please send a git-format patch, so I don't have to fight with
> patching tools for applying the patch.
>
I am attaching the patch created with git-format patch.  Thanks for your
time and valuable suggestions.

Thanks,
Senthil
-------------- next part --------------
A non-text attachment was scrubbed...
Name: special-characters-in-URL.patch
Type: application/octet-stream
Size: 2708 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130226/ad0115a9/attachment.obj>


More information about the ffmpeg-devel mailing list