aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--parse.y6
-rw-r--r--test/ruby/test_literal.rb7
3 files changed, 14 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 939427a134..d9a915dad7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Feb 24 08:52:09 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * parse.y (parser_tokadd_string, parser_yylex): insert a backslash
+ if the next character is non-ascii. [ruby-dev:45278] [Bug #6069]
+
Fri Feb 24 08:13:20 2012 Eric Hodel <drbrain@segment7.net>
* lib/profiler.rb: Add Profiler documentation by Gonzalo Rodriguez.
diff --git a/parse.y b/parse.y
index 82eb3d406a..3460c38518 100644
--- a/parse.y
+++ b/parse.y
@@ -6506,7 +6506,10 @@ parser_tokadd_string(struct parser_params *parser,
default:
if (c == -1) return -1;
- if (!ISASCII(c)) goto non_ascii;
+ if (!ISASCII(c)) {
+ tokadd('\\');
+ goto non_ascii;
+ }
if (func & STR_FUNC_REGEXP) {
pushback(c);
if ((c = tokadd_escape(&enc)) < 0)
@@ -7594,6 +7597,7 @@ parser_yylex(struct parser_params *parser)
}
else if (!lex_eol_p() && !(c = *lex_p, ISASCII(c))) {
nextc();
+ tokadd('\\');
if (tokadd_mbchar(c) == -1) return 0;
}
else {
diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb
index 23c1c9b800..85490d659b 100644
--- a/test/ruby/test_literal.rb
+++ b/test/ruby/test_literal.rb
@@ -74,12 +74,13 @@ class TestRubyLiteral < Test::Unit::TestCase
end
end
end
+ bug6069 = '[ruby-dev:45278]'
assert_equal "\x13", "\c\x33"
assert_equal "\x13", "\C-\x33"
assert_equal "\xB3", "\M-\x33"
- assert_equal "\u201c", eval(%["\\\u{201c}"]), bug5262
- assert_equal "\u201c".encode("euc-jp"), eval(%["\\\u{201c}"].encode("euc-jp")), bug5262
- assert_equal "\u201c".encode("iso-8859-13"), eval(%["\\\u{201c}"].encode("iso-8859-13")), bug5262
+ assert_equal "\\\u201c", eval(%["\\\u{201c}"]), bug6069
+ assert_equal "\\\u201c".encode("euc-jp"), eval(%["\\\u{201c}"].encode("euc-jp")), bug6069
+ assert_equal "\\\u201c".encode("iso-8859-13"), eval(%["\\\u{201c}"].encode("iso-8859-13")), bug6069
end
def test_dstring