ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: merch-redmine@jeremyevans.net
To: ruby-core@ruby-lang.org
Subject: [ruby-core:92650] [Ruby trunk Bug#15839] mixed encoding heredoc should be a syntax error regardless the order
Date: Wed, 15 May 2019 05:13:41 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-78012.20190515051339.376e0e1443943aa1@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15839.20190509064559@ruby-lang.org

Issue #15839 has been updated by jeremyevans0 (Jeremy Evans).

File mixed-encoding-heredoc-fix.patch added

Heredocs are parsed line-by-line, and mixed encoding is
already detected if it is on the same line:

```ruby
#encoding: cp932

p <<-STR
\xe9\x9d\u1234
STR
# UTF-8 mixed within Windows-31J source
# \xe9\x9d\u1234
# syntax error, unexpected end-of-input, expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END
```

In order to handle mixed content on separate lines, we need to
keep track of the temporary encoding of the string, which was
previously done via a local variable in `tokadd_string`. The
attached patch adds a second `rb_encoding **` argument to
`tokadd_string` for keeping track of the temporary encoding,
so that `here_document` can store the value between lines.

----------------------------------------
Bug #15839: mixed encoding heredoc should be a syntax error regardless the order
https://bugs.ruby-lang.org/issues/15839#change-78012

* Author: nobu (Nobuyoshi Nakada)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.4: REQUIRED, 2.5: REQUIRED, 2.6: REQUIRED
----------------------------------------
This heredoc isn't a syntax error,
```ruby
#encoding: cp932

p <<-STR
\xe9\x9d
\u1234
STR
```

whereas this is.
```ruby
#encoding: cp932
"
\xe9\x9d
\u1234
"
```

---Files--------------------------------
mixed-encoding-heredoc-fix.patch (5.28 KB)


-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2019-05-15  5:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-15839.20190509064559@ruby-lang.org>
2019-05-09  6:45 ` [ruby-core:92608] [Ruby trunk Bug#15839] mixed encoding heredoc should be a syntax error regardless the order nobu
2019-05-15  5:13 ` merch-redmine [this message]
2019-05-15  9:31 ` [ruby-core:92656] " nobu
2019-05-15 15:24 ` [ruby-core:92664] " merch-redmine
2019-05-15 23:24 ` [ruby-core:92673] " merch-redmine
2019-05-20  3:00 ` [ruby-core:92727] " nobu
2019-05-20  3:59 ` [ruby-core:92728] " merch-redmine
2019-08-01 13:56 ` [ruby-core:94096] [Ruby master " nagachika00
2019-08-26 15:36 ` [ruby-core:94572] " usa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-78012.20190515051339.376e0e1443943aa1@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).