[ruby-core:127565] [Ruby Bug#22597] Regexp named capture names with invalid source encoding
Issue #22597 has been reported by kddnewton (Kevin Newton). ---------------------------------------- Bug #22597: Regexp named capture names with invalid source encoding https://bugs.ruby-lang.org/issues/22597 * Author: kddnewton (Kevin Newton) * Status: Open * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- Parse.y uses the resolved encoding of a regexp when introducing named captures. Prism uses the source encoding. This almost always works, but: ``` # encoding: us-ascii /(?<\u3042>x)/ =~ "x" ``` This results in a "あ" UTF-8 local that is invisible to user code unless accessed through `binding.local_variable_get`. This is such a niche unrealistic use case I didn't even really want to report it. But for the sake of simplicity, could we say it's alright to not introduce local variables through regexp named captures that cannot be represented in the source encoding? -- https://bugs.ruby-lang.org/
Issue #22597 has been updated by nobu (Nobuyoshi Nakada). Backport changed from 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN to 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED Local variable definition by escaped form sounds insane. ---------------------------------------- Bug #22597: Regexp named capture names with invalid source encoding https://bugs.ruby-lang.org/issues/22597#change-120093 * Author: kddnewton (Kevin Newton) * Status: Open * Backport: 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED ---------------------------------------- Parse.y uses the resolved encoding of a regexp when introducing named captures. Prism uses the source encoding. This almost always works, but: ``` # encoding: us-ascii /(?<\u3042>x)/ =~ "x" ``` This results in a "あ" UTF-8 local that is invisible to user code unless accessed through `binding.local_variable_get`. This is such a niche unrealistic use case I didn't even really want to report it. But for the sake of simplicity, could we say it's alright to not introduce local variables through regexp named captures that cannot be represented in the source encoding? -- https://bugs.ruby-lang.org/
Issue #22597 has been updated by k0kubun (Takashi Kokubun). Backport changed from 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED to 3.3: REQUIRED, 3.4: REQUIRED, 4.0: DONE ruby_4_0 commit:89c2ca8b0f04198913251fe811aeda36337e6d5c merged revision(s) commit:441fc55bb1cbc616c59ee1b2b31dccd13ae2f8d9. ---------------------------------------- Bug #22597: Regexp named capture names with invalid source encoding https://bugs.ruby-lang.org/issues/22597#change-120118 * Author: kddnewton (Kevin Newton) * Status: Closed * Backport: 3.3: REQUIRED, 3.4: REQUIRED, 4.0: DONE ---------------------------------------- Parse.y uses the resolved encoding of a regexp when introducing named captures. Prism uses the source encoding. This almost always works, but: ``` # encoding: us-ascii /(?<\u3042>x)/ =~ "x" ``` This results in a "あ" UTF-8 local that is invisible to user code unless accessed through `binding.local_variable_get`. This is such a niche unrealistic use case I didn't even really want to report it. But for the sake of simplicity, could we say it's alright to not introduce local variables through regexp named captures that cannot be represented in the source encoding? -- https://bugs.ruby-lang.org/
participants (3)
-
k0kubun (Takashi Kokubun) -
kddnewton (Kevin Newton) -
nobu (Nobuyoshi Nakada)