Repository navigation
feat(os_functions): loadenv builtin - #1477
Conversation
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 20 out of 20 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| if (value.size() >= 2 && (value.front() == '"' && value.back() == '"')) { | ||
| return value.substr(1, value.size() - 2); | ||
| } | ||
|
|
There was a problem hiding this comment.
The strip_quotes function only handles double quotes but the .env file (sample.env) uses single quotes for all values. This will cause the quotes to not be stripped from the values. Add handling for single quotes: (value.front() == '\\'' && value.back() == '\\'') alongside the double quote check.
| if (value.size() >= 2 && (value.front() == '"' && value.back() == '"')) { | |
| return value.substr(1, value.size() - 2); | |
| } | |
| if (value.size() >= 2) { | |
| if ((value.front() == '"' && value.back() == '"') || | |
| (value.front() == '\'' && value.back() == '\'')) { | |
| return value.substr(1, value.size() - 2); | |
| } | |
| } |
|
|
||
| bool in_quotes = false; | ||
| std::string cleaned; | ||
|
|
||
| for (size_t i = 0; i < value.size(); ++i) { | ||
| char c = value[i]; | ||
|
|
||
| if (c == '"') | ||
| in_quotes = !in_quotes; | ||
|
|
||
| if (!in_quotes && c == '#') |
There was a problem hiding this comment.
The remove_inline_comment function only tracks double quotes but not single quotes. If the .env file contains single-quoted values with '#' characters inside, they will be incorrectly treated as comments. Add tracking for single quotes as well.
| bool in_quotes = false; | |
| std::string cleaned; | |
| for (size_t i = 0; i < value.size(); ++i) { | |
| char c = value[i]; | |
| if (c == '"') | |
| in_quotes = !in_quotes; | |
| if (!in_quotes && c == '#') | |
| bool in_single_quotes = false; | |
| bool in_double_quotes = false; | |
| std::string cleaned; | |
| for (size_t i = 0; i < value.size(); ++i) { | |
| char c = value[i]; | |
| if (c == '"' && !in_single_quotes) | |
| in_double_quotes = !in_double_quotes; | |
| else if (c == '\'' && !in_double_quotes) | |
| in_single_quotes = !in_single_quotes; | |
| if (!in_single_quotes && !in_double_quotes && c == '#') |
|
|
||
| FunctionDef* funcDef = nullptr; | ||
| if (!eval) { | ||
| Error(_W("Evaluator is not initialized.")); |
There was a problem hiding this comment.
After checking if eval is null and calling Error(), execution continues to line 61 where eval->getContext() is called. This can cause a null pointer dereference if eval is null. Add an early return after the Error() call on line 59.
| Error(_W("Evaluator is not initialized.")); | |
| Error(_W("Evaluator is not initialized.")); | |
| return retval; |
| } | ||
| Context* context = eval->getContext(); | ||
| if (!context) { | ||
| Error(_W("Context is not initialized.")); |
There was a problem hiding this comment.
After checking if context is null and calling Error(), execution continues to line 65 where context->lookupFunction() is called. This can cause a null pointer dereference if context is null. Add an early return after the Error() call on line 63.
| Error(_W("Context is not initialized.")); | |
| Error(_W("Context is not initialized.")); | |
| return retval; |
No description provided.