diff --git a/Ruby/README.md b/Ruby/README.md new file mode 100644 index 0000000..06687f8 --- /dev/null +++ b/Ruby/README.md @@ -0,0 +1,47 @@ +# Ruby + +## Commenting-Out + +Because of the lack of comments with a closing token this doesn't work +the same way as other languages. For more info see: + +https://github.com/nickboucher/trojan-source/issues/8#issuecomment-962468707 + +- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux] + +## Early Return + +Also does not work the same as other languages because of lack of closing token +on comments. See same link as above. + +- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux] + +## Homoglyph Function + +- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux] + +## Invisible Function + +- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux] + +## Stretched String + +- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux] + +# Variations + +Variations that may or may not be applicable in other languages. More info at: + +https://github.com/nickboucher/trojan-source/issues/9 + +## Stretched Regexp + +- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux] + +## Stretched String List + +- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux] + +## Stretched Variable + +- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux] diff --git a/Ruby/commenting-out.rb b/Ruby/commenting-out.rb new file mode 100755 index 0000000..1fe8942 --- /dev/null +++ b/Ruby/commenting-out.rb @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby + +is_admin = false +⁧⁦ = true; #⁩⁦if is_admin # Begin block if is_admin⁩⁩ + puts 'You are an admin.' +⁧⁦ = true; #⁩⁦end # End block if is_admin ⁩⁩ diff --git a/Ruby/early-return.rb b/Ruby/early-return.rb new file mode 100755 index 0000000..165ae78 --- /dev/null +++ b/Ruby/early-return.rb @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby + +$bank = { 'alice' => 100 } + +def subtract_funds account, amount + ⁧⁦ = amount and return # ⁩⁦# Subtract from acct the value⁩⁩ + $bank[account] -= amount +end + +subtract_funds 'alice', 50 +puts $bank.inspect diff --git a/Ruby/homoglyph-function.rb b/Ruby/homoglyph-function.rb new file mode 100755 index 0000000..d635b57 --- /dev/null +++ b/Ruby/homoglyph-function.rb @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby + +def sayНello + puts "Goodbye, World!" +end + +def sayHello + puts "Hello, World!" +end + +sayНello diff --git a/Ruby/invisible-functions.rb b/Ruby/invisible-functions.rb new file mode 100755 index 0000000..6fb7b5e --- /dev/null +++ b/Ruby/invisible-functions.rb @@ -0,0 +1,13 @@ +#!/usr/bin/env ruby + +def is_admin + false +end + +def is_​admin + true +end + +if is_​admin + puts "You are an admin." +end diff --git a/Ruby/stretched-regex.rb b/Ruby/stretched-regex.rb new file mode 100755 index 0000000..1658cf9 --- /dev/null +++ b/Ruby/stretched-regex.rb @@ -0,0 +1,10 @@ +#!/usr/bin/env ruby + +$roles = 'user,manager' +def admin? + $roles =~ /admin⁧⁦|user/ #⁩⁦/ # Restrict from ⁩⁩ +end + +if admin? + puts 'You are an admin.' +end diff --git a/Ruby/stretched-string-list.rb b/Ruby/stretched-string-list.rb new file mode 100755 index 0000000..88ad3a6 --- /dev/null +++ b/Ruby/stretched-string-list.rb @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby + +role = 'User' +privileged = %w(Admin Manager⁧⁦ User) # ⁩⁦) # All roles (except ⁩⁩ +if privileged.include? role + puts 'You are an admin.' +end diff --git a/Ruby/stretched-string.rb b/Ruby/stretched-string.rb new file mode 100755 index 0000000..2085bf3 --- /dev/null +++ b/Ruby/stretched-string.rb @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby + +access_level = "user" +if access_level != "user‮⁦" # Check if admin⁩⁦ + puts "You are an admin." +end diff --git a/Ruby/stretched-variable.rb b/Ruby/stretched-variable.rb new file mode 100755 index 0000000..5b9dd2e --- /dev/null +++ b/Ruby/stretched-variable.rb @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby + +role⁧⁦= 'Admin' #⁩⁦ # Condition will ensure 'User' !⁩⁦ = 'User'⁩⁩ +if role⁧⁦ == 'Admin' + puts 'You are an admin.' +end