aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2016-06-20 14:40:57 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2016-08-31 21:57:06 +0200
commite536abc1e1f59d1ac012e1be576bf55175e95443 (patch)
treec9ba9c5772f4e0551ccf309f1ac269678ebf77a8 /src
parent7e2348f2b1b487c875bbcf6c6711a276f9063040 (diff)
downloadrneovim-e536abc1e1f59d1ac012e1be576bf55175e95443.tar.gz
rneovim-e536abc1e1f59d1ac012e1be576bf55175e95443.tar.bz2
rneovim-e536abc1e1f59d1ac012e1be576bf55175e95443.zip
api: Allow blacklist functions that shouldn't be accesible from eval
Blacklist deprecated functions and functions depending on channel_id
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/buffer.c28
-rw-r--r--src/nvim/api/ui.c7
-rw-r--r--src/nvim/api/vim.c4
-rw-r--r--src/nvim/func_attr.h1
4 files changed, 27 insertions, 13 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index 029b645d3a..89fb7feaa9 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -56,6 +56,7 @@ Integer buffer_line_count(Buffer buffer, Error *err)
/// @param[out] err Details of an error that may have occurred
/// @return The line string
String buffer_get_line(Buffer buffer, Integer index, Error *err)
+ FUNC_API_NOEVAL
{
String rv = { .size = 0 };
@@ -84,6 +85,7 @@ String buffer_get_line(Buffer buffer, Integer index, Error *err)
/// @param line The new line.
/// @param[out] err Details of an error that may have occurred
void buffer_set_line(Buffer buffer, Integer index, String line, Error *err)
+ FUNC_API_NOEVAL
{
Object l = STRING_OBJ(line);
Array array = { .items = &l, .size = 1 };
@@ -102,6 +104,7 @@ void buffer_set_line(Buffer buffer, Integer index, String line, Error *err)
/// @param index The line index
/// @param[out] err Details of an error that may have occurred
void buffer_del_line(Buffer buffer, Integer index, Error *err)
+ FUNC_API_NOEVAL
{
Array array = ARRAY_DICT_INIT;
index = convert_index(index);
@@ -122,11 +125,12 @@ void buffer_del_line(Buffer buffer, Integer index, Error *err)
/// @param[out] err Details of an error that may have occurred
/// @return An array of lines
ArrayOf(String) buffer_get_line_slice(Buffer buffer,
- Integer start,
- Integer end,
- Boolean include_start,
- Boolean include_end,
- Error *err)
+ Integer start,
+ Integer end,
+ Boolean include_start,
+ Boolean include_end,
+ Error *err)
+ FUNC_API_NOEVAL
{
start = convert_index(start) + !include_start;
end = convert_index(end) + include_end;
@@ -229,12 +233,13 @@ end:
// array will simply delete the line range)
/// @param[out] err Details of an error that may have occurred
void buffer_set_line_slice(Buffer buffer,
- Integer start,
- Integer end,
- Boolean include_start,
- Boolean include_end,
- ArrayOf(String) replacement,
- Error *err)
+ Integer start,
+ Integer end,
+ Boolean include_start,
+ Boolean include_end,
+ ArrayOf(String) replacement,
+ Error *err)
+ FUNC_API_NOEVAL
{
start = convert_index(start) + !include_start;
end = convert_index(end) + include_end;
@@ -590,6 +595,7 @@ void buffer_insert(Buffer buffer,
Integer lnum,
ArrayOf(String) lines,
Error *err)
+ FUNC_API_NOEVAL
{
// "lnum" will be the index of the line after inserting,
// no matter if it is negative or not
diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c
index 2b131443d3..5426ccc8aa 100644
--- a/src/nvim/api/ui.c
+++ b/src/nvim/api/ui.c
@@ -48,6 +48,7 @@ void remote_ui_disconnect(uint64_t channel_id)
void nvim_ui_attach(uint64_t channel_id, Integer width, Integer height,
Dictionary options, Error *err)
+ FUNC_API_NOEVAL
{
if (pmap_has(uint64_t)(connected_uis, channel_id)) {
api_set_error(err, Exception, _("UI already attached for channel"));
@@ -117,6 +118,7 @@ void ui_attach(uint64_t channel_id, Integer width, Integer height,
}
void nvim_ui_detach(uint64_t channel_id, Error *err)
+ FUNC_API_NOEVAL
{
if (!pmap_has(uint64_t)(connected_uis, channel_id)) {
api_set_error(err, Exception, _("UI is not attached for channel"));
@@ -133,6 +135,7 @@ void ui_detach(uint64_t channel_id, Error *err)
void nvim_ui_try_resize(uint64_t channel_id, Integer width,
Integer height, Error *err)
+ FUNC_API_NOEVAL
{
if (!pmap_has(uint64_t)(connected_uis, channel_id)) {
api_set_error(err, Exception, _("UI is not attached for channel"));
@@ -159,7 +162,9 @@ void ui_try_resize(uint64_t channel_id, Integer width,
}
void nvim_ui_set_option(uint64_t channel_id, String name,
- Object value, Error *error) {
+ Object value, Error *error)
+ FUNC_API_NOEVAL
+{
if (!pmap_has(uint64_t)(connected_uis, channel_id)) {
api_set_error(error, Exception, _("UI is not attached for channel"));
return;
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index d4d2b72429..aa86e61e29 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -583,6 +583,7 @@ void vim_set_current_tabpage(Tabpage tabpage, Error *err)
/// @param channel_id The channel id (passed automatically by the dispatcher)
/// @param event The event type string
void vim_subscribe(uint64_t channel_id, String event)
+ FUNC_API_NOEVAL
{
size_t length = (event.size < METHOD_MAXLEN ? event.size : METHOD_MAXLEN);
char e[METHOD_MAXLEN + 1];
@@ -596,6 +597,7 @@ void vim_subscribe(uint64_t channel_id, String event)
/// @param channel_id The channel id (passed automatically by the dispatcher)
/// @param event The event type string
void vim_unsubscribe(uint64_t channel_id, String event)
+ FUNC_API_NOEVAL
{
size_t length = (event.size < METHOD_MAXLEN ?
event.size :
@@ -624,7 +626,7 @@ Dictionary vim_get_color_map(void)
Array vim_get_api_info(uint64_t channel_id)
- FUNC_API_ASYNC
+ FUNC_API_ASYNC FUNC_API_NOEVAL
{
Array rv = ARRAY_DICT_INIT;
diff --git a/src/nvim/func_attr.h b/src/nvim/func_attr.h
index ea017ab0c8..d98fe5b22b 100644
--- a/src/nvim/func_attr.h
+++ b/src/nvim/func_attr.h
@@ -185,6 +185,7 @@
#ifdef DEFINE_FUNC_ATTRIBUTES
# define FUNC_API_ASYNC
# define FUNC_API_NOEXPORT
+# define FUNC_API_NOEVAL
# define FUNC_ATTR_MALLOC REAL_FATTR_MALLOC
# define FUNC_ATTR_ALLOC_SIZE(x) REAL_FATTR_ALLOC_SIZE(x)
# define FUNC_ATTR_ALLOC_SIZE_PROD(x, y) REAL_FATTR_ALLOC_SIZE_PROD(x, y)