Граф коммитов

946 Коммитов

Автор SHA1 Сообщение Дата
Peter Zhu eca3680c27 [ruby/prism] Fix use of uninitialized value when parsing regexp
Parsing the regexp /\A{/ causes uses an uninitialized value because it
tries to parse it as a range quantifier, so it reads the character after
the closing curly bracket. This is using uninitialized values because
prism strings are not null terminated. This can be seen in the Valgrind
output:

    ==834710== Conditional jump or move depends on uninitialised value(s)
    ==834710==    at 0x5DA010: pm_regexp_parse_range_quantifier (regexp.c:163)
    ==834710==    by 0x5DA010: pm_regexp_parse_quantifier (regexp.c:243)
    ==834710==    by 0x5DAD69: pm_regexp_parse_expression (regexp.c:738)
    ==834710==    by 0x5DAD69: pm_regexp_parse_pattern (regexp.c:761)
    ==834710==    by 0x5DAD69: pm_regexp_parse (regexp.c:773)
    ==834710==    by 0x5A2EE7: parse_regular_expression_named_captures (prism.c:20886)
    ==834710==    by 0x5A2EE7: parse_expression_infix (prism.c:21388)
    ==834710==    by 0x5A5FA5: parse_expression (prism.c:21804)
    ==834710==    by 0x5A64F3: parse_statements (prism.c:13858)
    ==834710==    by 0x5A9730: parse_program (prism.c:22011)
    ==834710==    by 0x576F0D: parse_input_success_p (extension.c:1062)
    ==834710==    by 0x576F0D: parse_success_p (extension.c:1084)

This commit adds checks for the end of the string to
pm_regexp_parse_range_quantifier.

https://github.com/ruby/prism/commit/be6cbc23ef
2024-11-12 14:19:46 +00:00
Haldun Bayhantopcu 6767117b07 [ruby/prism] Fix splat after kwsplat
https://github.com/ruby/prism/commit/70c1cd480f
2024-11-08 15:50:54 +00:00
Kevin Newton 21af248f92 [ruby/prism] Error for def ivar
https://github.com/ruby/prism/commit/232a02acef
2024-11-03 18:43:18 +00:00
Aaron Patterson 3c9be02af1 [ruby/prism] Only read from buffer if `size` is greater than 0
It looks like we can possibly do an out of bounds read if size is equal
to 0.  This commit adds a conditional to ensure size is actually greater
than 0 before looking backwards in the buffer

https://github.com/ruby/prism/commit/2031b626e6
2024-10-28 20:38:20 +00:00
Kevin Newton 550ae745f6 [ruby/prism] Relocation
https://github.com/ruby/prism/commit/5ea6042408
2024-10-16 15:56:01 +00:00
S-H-GAMELINKS 6393d2950d [ruby/prism] Supress string_query function warning
https://github.com/ruby/prism/commit/0635814327
2024-10-13 12:22:58 +00:00
Kevin Newton 5f62522d5b [ruby/prism] Prism::StringQuery
Introduce StringQuery to provide methods to access some metadata
about the Ruby lexer.

https://github.com/ruby/prism/commit/d3f55b67b9
2024-10-11 19:34:57 +00:00
Kevin Newton ebbb093094 [ruby/prism] Short-circuit if possible for start line and unused warning
https://github.com/ruby/prism/commit/2745c81d31
2024-10-10 18:31:21 +00:00
Kevin Newton b5ecb03ae4 [ruby/prism] Do not warn for unused variables on negative lines
Fixes [Bug #20788]

https://github.com/ruby/prism/commit/27e91f21af
2024-10-10 15:13:10 +00:00
Kevin Newton 82c76f1896 [ruby/prism] Reject invalid splat as last statement of parentheses
https://github.com/ruby/prism/commit/3a0b1c6110
2024-10-10 14:45:59 +00:00
Stan Lo 4f9836be8d [ruby/prism] Update rescue node doc
Its `exception` field was renamed to `reference` in #1204 but the
documentation was not updated.

https://github.com/ruby/prism/commit/a477607ba2
2024-10-10 13:43:58 +00:00
Kevin Newton e39e582594 [ruby/prism] Attempt to assume binary is UTF-8
https://github.com/ruby/prism/commit/343197e4ff
2024-10-09 15:42:23 +00:00
Kevin Newton 4cbd2ab9d4 [ruby/prism] Properly handle non-assoc operators
https://github.com/ruby/prism/commit/dbd5c929d6
2024-10-07 17:57:36 +00:00
Kevin Newton 8d1906e8b7 [ruby/prism] Handle invalid commas in arguments, parameters, and arrays
https://github.com/ruby/prism/commit/023e894b74
2024-10-07 16:38:16 +00:00
Andrew Konchin 8d359644e7 [ruby/prism] Set contains_keywords flag for implicit gets($/, chomp: true) method call to handle -l CLI option
https://github.com/ruby/prism/commit/717e41c87d
2024-10-07 15:52:22 +00:00
Kevin Newton b8c8529dcf [ruby/prism] Fix up unary * binding power
https://github.com/ruby/prism/commit/c1d23d4702
2024-10-07 15:44:33 +00:00
Kevin Newton fa547b809a [ruby/prism] Fix up errors on invalid escape character syntax
https://github.com/ruby/prism/commit/14c8559378
2024-10-07 14:39:17 +00:00
Kevin Newton 5a95a69058 [ruby/prism] Fix up pattern parsing with trailing commas
https://github.com/ruby/prism/commit/51f2df60ff
2024-10-04 17:01:58 +00:00
Kevin Newton 75640037bf [ruby/prism] Fix up multi target parsing
https://github.com/ruby/prism/commit/80cd335222
2024-10-04 16:22:21 +00:00
Kevin Newton 568511f393 [ruby/prism] Handle single global variable character name
https://github.com/ruby/prism/commit/7a0af49997
2024-10-03 17:43:11 +00:00
Kevin Newton f8568fbd7f [ruby/prism] Pop lex mode for heredocs in the lexer, not the parser
https://github.com/ruby/prism/commit/5dd36b979e
2024-10-03 17:30:20 +00:00
Kevin Newton 77056674a0 [ruby/prism] Fix up binding power for singleton method receiver
https://github.com/ruby/prism/commit/f29ceae5cf
2024-10-02 18:39:20 +00:00
Kevin Newton 2610bf01b2 [ruby/prism] Fix up doubled range in arguments
https://github.com/ruby/prism/commit/aee2de91a3
2024-10-02 15:27:01 +00:00
Kevin Newton 2e2520ef10 [ruby/prism] Fix up beginless ranges in method definitions
https://github.com/ruby/prism/commit/ab9d80987a
2024-10-02 14:47:53 +00:00
Kevin Newton 467ebbebd9 [ruby/prism] Disallow dynamic patterns in labels at top level followed by pipes
https://github.com/ruby/prism/commit/ccc746f918
2024-10-01 15:42:44 -04:00
Kevin Newton ec230ac643 Resync to latest Prism 2024-10-01 11:03:25 -04:00
Kevin Newton d86b4041b5 [ruby/prism] Disallow empty labels when not allowed
https://github.com/ruby/prism/commit/399ee28dc1
2024-10-01 13:51:05 +00:00
Kevin Newton 75568d23e9 [ruby/prism] Disallow &. after endless range
https://github.com/ruby/prism/commit/498dd922d4
2024-10-01 12:57:00 +00:00
Kevin Newton 6c9b5c1615 Sync Prism with latest main branch 2024-09-30 11:36:29 -04:00
Kevin Newton c1c9ba77ca [ruby/prism] Require a delimiter for singleton classes
https://github.com/ruby/prism/commit/fd58d6a9ea
2024-09-30 14:33:58 +00:00
Daniel Insley 9a966a09cb [ruby/prism] Fix incorrect reference to AlternationPatternNode as non-void expressions
https://github.com/ruby/prism/commit/68de31919e
2024-09-26 15:47:51 +00:00
Daniel Insley a73d80db41 [ruby/prism] Add fields documentation for AliasMethodNode and AlternationPatternNode
https://github.com/ruby/prism/commit/6953daebde
2024-09-26 15:47:51 +00:00
Kevin Newton 1f431b63a2 [ruby/prism] Reject non-assoc ranges with subsequent operators
https://github.com/ruby/prism/commit/976a3cd0a5
2024-09-26 14:57:02 +00:00
Kevin Newton cab81d1bba [ruby/prism] Update templates/include/prism/ast.h.erb
https://github.com/ruby/prism/commit/dc7164e21c
2024-09-25 19:43:47 +00:00
Alexander Momchilov fa7fef270d [ruby/prism] Fix rendering of type overview docs
https://github.com/ruby/prism/commit/d42bc309cc
2024-09-25 19:43:47 +00:00
Kevin Newton be331c0eeb [ruby/prism] Fix up more error messages to more closely match parse.y
https://github.com/ruby/prism/commit/988ac82187
2024-09-25 19:19:18 +00:00
Kevin Newton 12cf9f2ae5 [ruby/prism] Fix up void value expression checking for rescue
https://github.com/ruby/prism/commit/509ff88e92
2024-09-25 18:34:51 +00:00
Kevin Newton 768ceceb12 [ruby/prism] Disallow label in parentheses
https://github.com/ruby/prism/commit/b624e09cc6
2024-09-25 17:33:51 +00:00
Kevin Newton a6ea4ddb4e [ruby/prism] Remove use of __assume to simplify
https://github.com/ruby/prism/commit/4daf58f7a0
2024-09-25 16:17:08 +00:00
Kevin Newton bf6109c8cc [ruby/prism] Fix up windows use of __assume
https://github.com/ruby/prism/commit/9fd0c0901e
2024-09-25 16:08:13 +00:00
Kevin Newton 57688cd625 [ruby/prism] Support a max depth to protect against malicious payloads
https://github.com/ruby/prism/commit/a474017bbe
2024-09-25 15:47:08 +00:00
Benoit Daloze cafd666adf [ruby/prism] Type every node field and mark on-error-only types explicitly
* For Loader.java, do not deserialize the AST if there are errors, so then Java nodes only have non-error types for fields.

https://github.com/ruby/prism/commit/ae78e3c605
2024-09-25 13:46:31 +00:00
Kevin Newton 414a848cc6 [ruby/prism] Accept version shorthand like 3.4
https://github.com/ruby/prism/commit/098f1c4607
2024-09-24 13:21:36 +00:00
Benoit Daloze ed4a55fc4d [ruby/prism] Accept all 3.3.x and 3.4.x Ruby versions for Prism.parse
https://github.com/ruby/prism/commit/a4fcd5339a
2024-09-24 12:24:19 +00:00
Benoit Daloze b8baf3f3ee [ruby/prism] check_string() should always return a valid C string
* Otherwise it is invalid e.g. to call strlen() to the result,
  or to assume the argument was a string.
* All callers are already checking for nil before.

https://github.com/ruby/prism/commit/8197be883e
2024-09-24 12:24:19 +00:00
Kevin Newton f515a1ab4b [ruby/prism] Introduce partial_script option
https://github.com/ruby/prism/commit/b28877fa4f
2024-09-20 15:42:12 +00:00
Jeremy Evans 268c72377b
Raise a compile error for break/next/redo inside eval in cases where it is optimized away
In cases where break/next/redo are not valid syntax, they should
raise a SyntaxError even if inside a conditional block that is
optimized away.

Fixes [Bug #20597]

Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2024-09-18 16:54:56 -07:00
Kevin Newton 96da3f16a0 [ruby/prism] Allow returns in default parameter values
https://github.com/ruby/prism/commit/e98ea15596
2024-09-18 11:52:27 -04:00
Kevin Newton 748933aa1b [ruby/prism] Accept "do" blocks in some parameter default values
https://github.com/ruby/prism/commit/6d7b734dbe
2024-09-17 18:47:27 +00:00
Kevin Newton 7e2ae30f8b [ruby/prism] Handle retry doubly nested under rescue
Fixes [Bug #20747]

https://github.com/ruby/prism/commit/d3194715a9
2024-09-16 19:55:29 +00:00