From: "nobu (Nobuyoshi Nakada) via ruby-core" Date: 2023-03-30T16:21:45+00:00 Subject: [ruby-core:113053] [Ruby master Bug#19558] str.dump.undump crashes when str contains both Unicode and ASCII control characters Issue #19558 has been updated by nobu (Nobuyoshi Nakada). https://github.com/nobu/ruby/tree/undump-ctrl ---------------------------------------- Bug #19558: str.dump.undump crashes when str contains both Unicode and ASCII control characters https://bugs.ruby-lang.org/issues/19558#change-102591 * Author: ikaronen-relex (Ilmari Karonen) * Status: Open * Priority: Normal * ruby -v: ruby 3.3.0dev (2023-03-29T10:20:29Z master 02ecdf85c5) [x86_64-darwin21] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- Recently, as a result of a question I asked on Stack Overflow (https://stackoverflow.com/q/75866159), I learned about the existence of String#dump and String#undump. However, I also found what seems like a bug in them, in that apparently dumping and then undumping a string containing a sufficiently diverse selection of characters (such as at least one ASCII C0 control character and at least one non-ASCII Unicode character) causes the undump to raise a RuntimeError. Specifically, evaluating e.g. any of the following expressions: "\u0000\uFFFF".dump.undump "\u0001\uABCD".dump.undump "\u007F\u0080".dump.undump raises a RuntimeError with the message "hex escape and Unicode escape are mixed". This contradicts the documentation of String#undump, which says that it "does the inverse of String#dump." The behavior is the same on all Ruby versions I have tested this on, including master (3.3.0), 2.6.10 and JRuby 9.3.10.0. The obvious fix would be to simply remove the check for mixed hex and Unicode escape sequences, essentially reverting https://github.com/ruby/ruby/commit/05d1d29d1f4a87620371463d8c7942e170be031f. However, as I don't understand why the check is there in the first place, I'm also not sure if removing it could somehow have some unwanted consequences. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/