瀏覽代碼

do not treat \0 as a backref in BRE

The valid BRE backref tokens are \1 .. \9, and 0 is not a special
character either so \0 is undefined by the standard.

Such undefined escaped characters are treated as literal characters
currently, following existing practice, so \0 is the same as 0.
Szabolcs Nagy 10 年之前
父節點
當前提交
32dee9b9b1
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/regex/regcomp.c

+ 1 - 1
src/regex/regcomp.c

@@ -839,7 +839,7 @@ static reg_errcode_t parse_atom(tre_parse_ctx_t *ctx, const char *s)
 			s--;
 			break;
 		default:
-			if (!ere && isdigit(*s)) {
+			if (!ere && (unsigned)*s-'1' < 9) {
 				/* back reference */
 				int val = *s - '0';
 				node = tre_ast_new_literal(ctx->mem, BACKREF, val, ctx->position);