Ivan Giuliani 065b48177b
[Ruby] Fix incorrect escaping of Ruby forward slashes (#16474)
* [Ruby] Test correct escaping of pattern sequences

Ruby is not correctly escaping pattern sequences containing forward
slashes in their definition. This commit adds tests that verify the
correct behaviour of the code generator.

See issue #5582.

* [Ruby] Correctly escape patterns containing forward slashes

Ruby regexs are always generated as match patterns enclosed in slash
characters (i.e. using the `/pattern/` syntax). Regular expressions
defined in the OpenAPI declaration via the `pattern` attribute follow
[ECMA 262](https://262.ecma-international.org/5.1/#sec-15.10.1) which
means they already include the correct escaping of forward slashes as
far as Ruby is concerned.

The current Ruby codegen is incorrectly escaping all forward slashes,
which ultimately causes the generated code to include additional
incorrect escape sequences which cause the generated file to have an
invalid syntax.

This commit ports the same fix introduced in #1539 for the Python
codegen, as both Ruby and Python use perl-flavored regular expressions
so they behave in the same way when it comes to escaping forward
slashes.

Fixes #5582.
2023-09-05 20:12:29 +08:00
..
2023-08-25 16:11:29 +08:00