mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 14:43:55 +08:00
Skip long arguments in syntax highlighting path detection
When fish performs syntax highlighting, it attempts to determine which arguments are valid paths and underline them. Skip paths whose length exceeds PATH_MAX. This is an optimization: such strings are almost certainly not valid paths and checking them may be expensive. Relevant is #7837
This commit is contained in:
parent
cf35431af9
commit
8d54d2b60e
|
@ -918,6 +918,11 @@ void highlighter_t::color_as_argument(const ast::node_t &node) {
|
|||
static bool range_is_potential_path(const wcstring &src, const source_range_t &range,
|
||||
const operation_context_t &ctx,
|
||||
const wcstring &working_directory) {
|
||||
// Skip strings exceeding PATH_MAX. See #7837.
|
||||
// Note some paths may exceed PATH_MAX, but this is just for highlighting.
|
||||
if (range.length > PATH_MAX) {
|
||||
return false;
|
||||
}
|
||||
// Get the node source, unescape it, and then pass it to is_potential_path along with the
|
||||
// working directory (as a one element list).
|
||||
bool result = false;
|
||||
|
|
Loading…
Reference in New Issue
Block a user