Project

General

Profile

ActionsLike0

Bug #18337

open

Ruby allows zero-width characters in identifiers

Added by duerst (Martin Dürst) over 3 years ago. Updated over 3 years ago.

Status:
Assigned
Target version:
-
[ruby-core:106056]

Description

Ruby allows zero-width characters in identifiers, which can be shown with the following small test:

irb(main):001:0> script = "ab = 20; a\u200Bb = 30; puts ab;"
=> "ab = 20; a​b = 30; puts ab;"
irb(main):002:0> eval(script)
20
=> nil

The first line creates the script. It contains a zero-width space (ZWSP), but that's not visible in most contexts (see next line). Looking at the script, one expects 30 as an output, but the output is 20 because there are two variables involved, one with a ZWSP and one without. I propose we fix this by disallowing such characters in identifiers. I'll give more details in a followup.


Related issues 1 (0 open1 closed)

Related to Ruby - Feature #18336: How to deal with Trojan Source vulnerabilityFeedbackActions
#1

Updated by duerst (Martin Dürst) over 3 years ago

  • Related to Feature #18336: How to deal with Trojan Source vulnerability added

Updated by duerst (Martin Dürst) over 3 years ago

  • Status changed from Open to Assigned
  • Assignee set to duerst (Martin Dürst)
ActionsLike0

Also available in: Atom PDF