0
0
mirror of https://github.com/vim/vim.git synced 2025-07-04 23:07:33 -04:00

359 Commits

Author SHA1 Message Date
Christian Brabandt
9198c1f2b1
patch 9.0.2068: [security] overflow in :history
Problem:  [security] overflow in :history
Solution: Check that value fits into int

The get_list_range() function, used to parse numbers for the :history
and :clist command internally uses long variables to store the numbers.
However function arguments are integer pointers, which can then
overflow.

Check that the return value from the vim_str2nr() function is not larger
than INT_MAX and if yes, bail out with an error. I guess nobody uses a
cmdline/clist history that needs so many entries... (famous last words).

It is only a moderate vulnerability, so impact should be low.

Github Advisory:
https://github.com/vim/vim/security/advisories/GHSA-q22m-h7m2-9mgm

Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-10-26 21:29:32 +02:00
Ernie Rael
d4802ec485
patch 9.0.2055: Vim9: non-consistent error messages
Problem:  Vim9: non-consistent error messages
Solution: make error messages more consistent with common structure

Adjust vim9class messages to follow common pattern.
[Variable|Method] "var-or-meth-name" ... class "class-name"

closes: #13391

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Ernie Rael <errael@raelity.com>
2023-10-20 11:59:00 +02:00
Illia Bobyr
8079917447
patch 9.0.2041: trim(): hard to use default mask
Problem:  trim(): hard to use default mask (partly revert v9.0.2040)
Solution: use default mask when it is empty

The default 'mask' value is pretty complex, as it includes many
characters.  Yet, if one needs to specify the trimming direction, the
third argument, 'trim()' currently requires the 'mask' value to be
provided explicitly.

Currently, an empty 'mask' will make 'trim()' call return 'text' value
that is passed in unmodified.  It is unlikely that someone is using it,
so the chances of scripts being broken by this change are low.

Also, this reverts commit 9.0.2040 (which uses v:none for the default
and requires to use an empty string instead).

closes: #13358

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Illia Bobyr <illia.bobyr@gmail.com>
2023-10-17 18:06:00 +02:00
Illia Bobyr
6e6386716f
patch 9.0.2040: trim(): hard to use default mask
Problem:  trim(): hard to use default mask
Solution: Use default 'mask' when it is v:none

The default 'mask' value is pretty complex, as it includes many
characters.  Yet, if one needs to specify the trimming direction, the
third argument, 'trim()' currently requires the 'mask' value to be
provided explicitly.

'v:none' is already used to mean "use the default argument value" in
user defined functions.  See |none-function_argument| in help.

closes: #13363

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Illia Bobyr <illia.bobyr@gmail.com>
2023-10-17 11:09:45 +02:00
Viktor Szépe
dbf749bd5a
runtime: Fix more typos (#13354)
* Fix more typos

* Fix typos in ignored runtime/ directory

Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-10-16 09:53:37 +02:00
Ernie Rael
f8da324619
patch 9.0.2012: Vim9: error message can be more accurate
Problem:  Vim9: error message can be more accurate
Solution: Fix the error messages

Fix message for some single use error messages.

closes: #13312

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Ernie Rael <errael@raelity.com>
2023-10-11 21:22:12 +02:00
Christ van Willegen
ea746f9e86
patch 9.0.1990: strange error number
Problem:  strange error number
Solution: change error number,
          add doc tag for E1507

closes: #13270

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>
2023-10-05 20:48:36 +02:00
Ernie Rael
64885645e7
patch 9.0.1982: vim9: clean up from v9.0.1955
Problem:  vim9: clean up from v9.0.1955
Solution: Fix a few remaining issues, improve error message

- Use `cl_exec`, the executing class, to check permissions in `get_lval()`.
- Handle lockvar of script variable from class.
- Add 'in class "Xxx"' to e_cannot_access_private_variable_str.

closes: #13222

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Ernie Rael <errael@raelity.com>
2023-10-04 20:16:22 +02:00
Gene C
993b17569b
patch 9.0.1975: xattr: permission-denied errors on write
Problem:  xattr: permission-denied errors on write
Solution: ignore those errors

closes: #13246

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Gene C <arch@sapience.com>
2023-10-02 22:44:12 +02:00
zeertzjq
7ece036d72
patch 9.0.1967: xattr errors not translated
Problem:  xattr errors not translated
Solution: mark for translation, consistently capitalize
          first letter.

closes: #13236

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2023-10-01 09:07:14 +02:00
Christian Brabandt
e085dfda5d
patch 9.0.1962: No support for writing extended attributes
Problem:  No support for writing extended attributes
Solution: Add extended attribute support for linux

It's been a long standing issue, that if you write a file with extended
attributes and backupcopy is set to no, the file will loose the extended
attributes.

So this patch adds support for retrieving the extended attributes and
copying it to the new file. It currently only works on linux, mainly
because I don't know the different APIs for other systems (BSD, MacOSX and
Solaris).  On linux, this should be supported since Kernel 2.4 or
something, so this should be pretty safe to use now.

Enable the extended attribute support with normal builds.

I also added it explicitly to the :version output as well as make it
able to check using `:echo has("xattr")`, to have users easily check
that this is available.

In contrast to the similar support for SELINUX and SMACK support (which
also internally uses extended attributes), I have made this a FEAT_XATTR
define, instead of the similar HAVE_XATTR.

Add a test and change CI to include relevant packages so that CI can
test that extended attributes are correctly written.

closes: #306
closes: #13203

Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-09-30 12:49:18 +02:00
Ernie Rael
ee865f37ac
patch 9.0.1955: Vim9: lockvar issues with objects/classes
Problem:  Vim9: lockvar issues with objects/classes
Solution: fix `get_lhs()` object/class access and avoid `SEGV`,
          make error messages more accurate.

- `get_lval()` detects/returns object/class access
- `compile_lock_unlock()` generate code for bare static and obj_arg access
- `do_lock_var()` check lval for `ll_object`/`ll_class` and fail if so.

Details:
- Add `ll_object`/`ll_class`/`ll_oi` to `lval_T`.
- Add `lockunlock_T` to `isn_T` for `is_arg` to specify handling of `lval_root` in `get_lval()`.
- In `get_lval()`, fill in `ll_object`/`ll_class`/`ll_oi` as needed; when no `[idx] or .key`, check lval_root on the way out.
- In `do_lock_var()` check for `ll_object`/`ll_class`; also bullet proof ll_dict case
  and give `Dictionay required` if problem. (not needed to avoid lockvar crash anymore)
- In `compile_lock_unlock()` compile for the class variable and func arg cases.

closes: #13174

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Ernie Rael <errael@raelity.com>
2023-09-29 19:53:55 +02:00
Ken Takata
789b8854d2
patch 9.0.1953: Misplaced comment in errors.h
Problem:  Misplaced comment in errors.h
Solution: Move it up

closes: #13218

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Ken Takata <kentkt@csc.jp>
2023-09-29 19:45:42 +02:00
Yegappan Lakshmanan
b90e3bc491
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Problem:  Vim9: hard to debug vim9_class errors from CI
Solution: Include the line number in assert_xxx() calls.  Include the
          entire error message in the tests.  Fix the indentation in the
          test file.  Add tags for new error codes.

closes: #13206

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-28 23:16:35 +02:00
Yegappan Lakshmanan
413f83990f
patch 9.0.1950: Vim9: error codes spread out
Problem:  Vim9: error codes spread out
Solution: group them together and reserve 100
          more for future use

Reserve 100 error codes for future enhancements to the Vim9 class
support

closes: #13207

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-28 22:46:37 +02:00
h-east
db38552dcd
patch 9.0.1948: Vim9: object variable "this." should only be used in constructor
Problem:  Vim9: object variable "this." should only be used in
          constructor
Solution: Disallow to this in normal object methods (other than
          constructors)

closes: #13152
closes: #13212

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: h-east <h.east.727@gmail.com>
2023-09-28 22:18:19 +02:00
Yegappan Lakshmanan
2dede3dbfa
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Problem:  Vim9: missing support for ro-vars in interface
Solution: Support only read-only object variables in an interface,
          add additional checks when parsing class definitions.

closes: #13183
cloess: #13184
cloess: #13185.
closes: #13188

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-27 19:02:01 +02:00
RestorerZ
7fe8f43f49
patch 9.0.1935: Vim9: not consistent error messages
Problem:  Vim9: not consistent error messages
Solution: Make error messages more consistent. Use "variable" for
          (object/class) member

closes: #13155

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: RestorerZ <restorer@mail2k.ru>
2023-09-24 23:21:24 +02:00
zeertzjq
edcba96c00
patch 9.0.1933: Can change the type of a v: variable using if_lua
Problem:  Can change the type of a v: variable using if_lua.
Solution: Add additional handling of v: variables like :let.

closes: #13161

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2023-09-24 23:13:51 +02:00
Ernie Rael
696270bcae
patch 9.0.1926: Vim9: not enough info in error message
Problem:  Vim9: not enough info in error message
Solution: Add class name, change member to variable, quote names

closes: #13136

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Ernie Rael <errael@raelity.com>
2023-09-21 16:42:28 +02:00
Yegappan Lakshmanan
00cd18222e
patch 9.0.1909: Vim9: problem calling class method from other class
Problem:  Vim9: problem calling class method from other class
Solution: Fix this problem, fix readonly object access, update error
          messages.

Calling a class method from another method without the class name prefix
doesn't work properly.

A readonly object variable is modifiable outside the class using a
nested object assignment.

Remove the unused E1338 error message.

Update error messages.

closes: #13116

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-18 19:56:49 +02:00
Yegappan Lakshmanan
92d9ee5f4c
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Problem:  Vim9: Interfaces should not support class methods and
          variables
Solution: Make sure interface follow the interface specification

Vim9 interface changes to follow the new interface specification:

1) An interface can have only read-only and read-write instance
   variables.
2) An interface can have only public instance methods.
3) An interface cannot have class variables and class methods.
4) An interface cannot have private instance variables and private
   instance methods.
5) A interface can extend another interface using "extends". The
   sub-interface gets all the variables and methods in the super
   interface.

That means:
- Interfaces should not support class methods and variables.
- Adjust error numbers and add additional tests.
- Interface methods can be defined in one of the super classes.
- Interface variables can be defined in one of the super classes.
  and instance variables can be repeated in sub interfaces.
- Check the class variable types with the type in interface.

closes: #13100

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-17 17:03:19 +02:00
Yegappan Lakshmanan
c30a90d9b2
patch 9.0.1898: Vim9: restrict access to static vars
Problem:  Vim9: restrict access to static vars and methods
Solution: Class members are accesible only from the class where they are
          defined.

Based on the #13004 discussion, the following changes are made:

    1) Static variables and methods are accessible only using the class
       name and inside the class where they are defined.
    2) Static variables and methods can be used without the class name in
       the class where they are defined.
    3) Static variables of a super class are not copied to the sub class.
    4) A sub class can declare a class variable with the same name as the
       super class.
    5) When a method or member is found during compilation, use more
       specific error messages.

This aligns the Vim9 class variable/method implementation with the Dart
implementation.

Also while at it, ignore duplicate class and object methods.

The access level of an object method can however be changed in a
subclass.

For the tests, use the new CheckSourceFailure() function instead of the
CheckScriptFailure() function in the tests.

closes: #13086

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-15 20:14:55 +02:00
Christian Brabandt
ee17b6f70d
patch 9.0.1886: Various Typos
Problem:  Various Typos
Solution: Fix Typos

This is a collection of typo related commits.

closes: #12753
closes: #13016

Co-authored-by: Adri Verhoef <a3@a3.xs4all.nl>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: Viktor Szépe <viktor@szepe.net>
Co-authored-by: nuid64 <lvkuzvesov@proton.me>
Co-authored-by: Meng Xiangzhuo <aumo@foxmail.com>
Co-authored-by: Dominique Pellé <dominique.pelle@gmail.com>

Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-09-09 11:31:38 +02:00
Yegappan Lakshmanan
7bcd25cad3
patch 9.0.1885: Vim9: no support for abstract methods
Problem:  Vim9: no support for abstract methods
Solution: Add support for defining abstract methods in an abstract class

closes: #13044
closes: #13046

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-08 19:29:31 +02:00
Christ van Willegen
1bd2cb1169
patch 9.0.1884: Wrong order of arguments for error messages
Problem:  Wrong order of arguments for error messages
Solution: Reverse order or arguments for e_aptypes_is_null_nr_str

closes: #13051

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>
2023-09-08 19:18:58 +02:00
Ernie Rael
18143d3111
patch 9.0.1867: Vim9: access to interface statics possible
Problem:  Vim9: access to interface statics possible
Solution: Prevent direct access to interface statics

closes: #13007

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Ernie Rael <errael@raelity.com>
2023-09-04 22:30:41 +02:00
zeertzjq
7db89bdc23
patch 9.0.1863: wrong format specifiers in e_aptypes_is_null_str_nr
Problem:  wrong format specifiers in e_aptypes_is_null_str_nr
Solution: Fix the wrong format specifier

closes: #13020

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2023-09-04 07:54:02 +02:00
Christ van Willegen
aa90d4f031
patch 9.0.1856: issues with formatting positional arguments
Problem:  issues with formatting positional arguments
Solution: fix them, add tests and documentation

closes: #12140
closes: #12985

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>
Tentatively fix message_test. Check NULL ptr.
2023-09-03 17:22:37 +02:00
Yegappan Lakshmanan
eb91e24d5e
patch 9.0.1829: Vim9 missing access-checks for private vars
Problem:  Vim9 missing access-checks for private vars
Solution: Use the proper check for private/readonly variable.  Access
          level for a member cannot be changed in a class implementing an
          interface.  Update the code indentation

closes: #12978

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Co-authored-by: Ernie Rael <errael@raelity.com>
2023-08-31 18:10:46 +02:00
Yegappan Lakshmanan
e3b6c78ddc
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Problem:  Vim9: no check for duplicate members in extended classes
Solution: Check for duplicate members in extended classes.
          Fix memory leak.

closes: #12948

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-29 22:34:36 +02:00
Gianmaria Bajo
4b9777a1df
patch 9.0.1821: Vim9 constructors are always static
Problem:  Vim9 constructors are always static
Solution: make the "static" keyword an error

closes: #12945

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Gianmaria Bajo <mg1979.git@gmail.com>
2023-08-29 22:29:03 +02:00
Yegappan Lakshmanan
2ba9d2e14e
patch 9.0.1814: Vim9 no error on duplicate object member var
Problem:  Vim9 no error on duplicate object member var
Solution: detect duplicate members and error out

closes: #12938

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-28 21:26:23 +02:00
Yegappan Lakshmanan
cd7293bf6c
patch 9.0.1804: Vim9: no support for private object methods
Problem:  Vim9: no support for private object methods
Solution: Add support for private object/class methods

closes: #12920

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-27 19:18:23 +02:00
LemonBoy
afe0466fb1
patch 9.0.1786: Vim9: need instanceof() function
Problem:  Vim9: need instanceof() function
Solution: Implement instanceof() builtin

Implemented in the same form as Python's isinstance because it allows
for checking multiple class types at the same time.

closes: #12867

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: LemonBoy <thatlemon@gmail.com>
2023-08-23 21:08:11 +02:00
Yegappan Lakshmanan
6ac1544e13
patch 9.0.1760: vim9 class problem with new() constructor
Problem:  vim9 class problem with new() constructor
Solution: Don't allow a return type for the new() class constructor.

closes: #12863
closes: #12040

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-20 18:20:17 +02:00
LemonBoy
c5d2744c04
patch 9.0.1741: No type checking in interfaces
Problem: No type checking in interfaces
Solution: Implement member type check in vim9 interfaces

Most of the code is a small refactoring to allow the use of a where_T
for signaling the type mismatch, the type checking itself is pretty
simple.

Improve where_T error reports

Let the caller explicitly define the kind of location it's referring to
and free the WT_ARGUMENT enum from its catch-all role.

Implement type checking for interface methods

Follows closely the logic used for type-checking the members.

closes: #12844

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: LemonBoy <thatlemon@gmail.com>
2023-08-19 13:04:53 +02:00
zeertzjq
4f389e7c0f
patch 9.0.1722: wrong error messages when passing wrong types to count()
Problem: wrong error messages when passing wrong types to count()
Solution: fix it

This fixes two problems:
1. When passing wrong type to {ic} argument of count(), two error
   messages are given, the second of which is misleading.
2. When passing wrong type to {comp} argument of count(), the error
   message doesn't mention that {comp} may be a String.

closes: #12825

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2023-08-17 22:11:16 +02:00
Christ van Willegen
0c6181fec4
patch 9.0.1704: Cannot use positional arguments for printf()
Problem: Cannot use positional arguments for printf()
Solution: Support positional arguments in string formatting

closes: #12140

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>
2023-08-13 18:06:00 +02:00
Bram Moolenaar
80adaa8ae8 patch 9.0.1673: cannot produce a status 418 or 503 message
Problem:    Cannot produce a status 418 or 503 message.
Solution:   Add err_teapot().
2023-07-07 18:57:40 +01:00
RestorerZ
68ebcee023 patch 9.0.1594: some internal error messages are translated
Problem:    Some internal error messages are translated.
Solution:   Consistently do not translate internal error messages.
            (closes #12459)
2023-05-31 17:12:14 +01:00
Bram Moolenaar
a1d5f9f33c patch 9.0.1581: translation does not work for plural argument
Problem:    Translation does not work for plural argument.
Solution:   Use PLURAL_MSG() for errors and with xgettext. (closes #12443)
2023-05-27 13:40:11 +01:00
RestorerZ
d87dec0582 patch 9.0.1579: some error messages are not translated
Problem:    Some error messages are not translated.
Solution:   Add the N_() marker on messages. (closes #12427)
2023-05-25 20:13:48 +01:00
Bram Moolenaar
097c5370ea patch 9.0.1576: users may not know what to do with an internal error
Problem:    Users may not know what to do with an internal error.
Solution:   Add a translated message with instructions.
2023-05-24 21:02:24 +01:00
Bram Moolenaar
a2c0028fdf patch 9.0.1558: wrong error for unreachable code after :throw
Problem:    Wrong error for unreachable code after :throw.
Solution:   Adjust the error message.
2023-05-14 22:05:15 +01:00
zeertzjq
3ab3a86481 patch 9.0.1516: cannot use special keys in <Cmd> mapping
Problem:    Cannot use special keys in <Cmd> mapping.
Solution:   Do allow for special keys in <Cmd> and <ScriptCmd> mappings.
            (closes #12326)
2023-05-06 16:22:04 +01:00
Bram Moolenaar
70e8028a4d patch 9.0.1510: misleading variable name for error message
Problem:    Misleading variable name for error message.
Solution:   Change "name" to "number".  (closes #12345)
2023-05-05 22:58:34 +01:00
Bram Moolenaar
b67ba03d3e patch 9.0.1477: crash when recovering from corrupted swap file
Problem:    Crash when recovering from corrupted swap file.
Solution:   Check for a valid page count. (closes #12275)
2023-04-22 21:14:26 +01:00
Bram Moolenaar
08210f8def patch 9.0.1450: MacOS: building fails if clock_gettime() is not available
Problem:    MacOS: building fails if clock_gettime() is not available.
Solution:   Add a configure check for clock_gettime(). (closes #12242)
2023-04-13 19:15:54 +01:00
Dominique Pelle
e764d1b421 patch 9.0.1403: unused variables and functions
Problem:    Unused variables and functions.
Solution:   Delete items and adjust #ifdefs. (Dominique Pellé, closes #12145)
2023-03-12 21:20:59 +00:00