[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnash-commit] gnash ChangeLog server/asobj/Global.cpp testsui...
From: |
strk |
Subject: |
Re: [Gnash-commit] gnash ChangeLog server/asobj/Global.cpp testsui... |
Date: |
Thu, 1 Feb 2007 21:08:55 +0100 |
On Thu, Feb 01, 2007 at 07:35:37PM +0000, Martin Guy wrote:
> Log message:
> Implement ActionScript 5 "escape" method and testsuite clauses
...
> +/// \brief Encode a string to URL-encoded format
> +/// converting all dodgy characters to %AB hex sequences
> +// "Dodgy" means
> +// - ASCII control characters: 0-31 and 127
> +// - Non-ASCII chars: 128-255
> +// - URL syntax characters: $ & + , / : ; = ? @
> +// - Unsafe characters: SPACE " < > # % { } | \ ^ ~ [ ] `
> +// Encoding is a % followed by two hexadecimal characters, case insensitive.
> +// See RFC1738 http://www.rfc-editor.org/rfc/rfc1738.txt,
> +// Section 2.2 "URL Character Encoding Issues"
If you keep the triple slashes after the brief description, the comment
will end up in the "long" description when creating the doxygen page:
/// \brief ...
/// brief desc continues
//
/// Long description
/// here
> +static void
> +as_global_escape(const fn_call& fn)
> +{
> + // List of chars we must convert to escape sequences
> + // (list taken from crazy case statement in as_global_unescape)
> + const string escapees = " \"#$%&+,/:;<=>address@hidden|}~";
> + const string hexdigits = "0123456789ABCDEF";
> +
> + assert(fn.nargs == 1);
We use asserts often, but calling _global.excape(any, number, of, args)
is completely legit in ActionScript, so we'd do a better job with something
like:
if ( fn.nargs < 1 )
{
IF_VERBOSE_ASCODING_ERROS(
log_aserror("_global.escape() needs one argument");
);
return;
}
else if ( fn.nargs > 1 )
{
IF_VERBOSE_ASCODING_ERROS(
log_aserror("More then 1 args given to _global.escape());
);
// just discard the rest...
}
> + string input = fn.arg(0).to_string();
Note that to_string() might return NULL, in which case
the std::string constructor will segfault.
--strk;