diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-02-03 17:39:19 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-02-03 17:39:19 -0200 |
| commit | cbf0c7a103bd69a2b8d8a55f676cf7bb08058909 (patch) | |
| tree | 3dfb9fb0d458527e6d4e7e486884611abe9afedb | |
| parent | 4c399c5dfbb094d4bd151d49abd3d998ed1d757d (diff) | |
| download | lua-cbf0c7a103bd69a2b8d8a55f676cf7bb08058909.tar.gz lua-cbf0c7a103bd69a2b8d8a55f676cf7bb08058909.tar.bz2 lua-cbf0c7a103bd69a2b8d8a55f676cf7bb08058909.zip | |
check for invalid use of '%' in replacement string in 'string.gsub'
| -rw-r--r-- | lstrlib.c | 8 |
1 files changed, 6 insertions, 2 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstrlib.c,v 1.140 2008/04/14 15:54:59 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.141 2008/06/12 14:21:18 roberto Exp roberto $ |
| 3 | ** Standard library for string operations and pattern-matching | 3 | ** Standard library for string operations and pattern-matching |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -600,8 +600,12 @@ static void add_s (MatchState *ms, luaL_Buffer *b, const char *s, | |||
| 600 | luaL_addchar(b, news[i]); | 600 | luaL_addchar(b, news[i]); |
| 601 | else { | 601 | else { |
| 602 | i++; /* skip ESC */ | 602 | i++; /* skip ESC */ |
| 603 | if (!isdigit(uchar(news[i]))) | 603 | if (!isdigit(uchar(news[i]))) { |
| 604 | if (news[i] != L_ESC) | ||
| 605 | luaL_error(ms->L, "invalid use of " LUA_QL("%c") | ||
| 606 | " in replacement string", L_ESC); | ||
| 604 | luaL_addchar(b, news[i]); | 607 | luaL_addchar(b, news[i]); |
| 608 | } | ||
| 605 | else if (news[i] == '0') | 609 | else if (news[i] == '0') |
| 606 | luaL_addlstring(b, s, e - s); | 610 | luaL_addlstring(b, s, e - s); |
| 607 | else { | 611 | else { |
