mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Fix path compression to include removing "/./".
- This involved a fix to the FTP scripts that relied on the old behavior.
This commit is contained in:
parent
d11a1dab73
commit
f1d165956a
3 changed files with 12 additions and 6 deletions
|
@ -56,10 +56,10 @@ export {
|
||||||
tags: set[string] &log &default=set();
|
tags: set[string] &log &default=set();
|
||||||
|
|
||||||
## Current working directory that this session is in. By making
|
## Current working directory that this session is in. By making
|
||||||
## the default value '/.', we can indicate that unless something
|
## the default value '.', we can indicate that unless something
|
||||||
## more concrete is discovered that the existing but unknown
|
## more concrete is discovered that the existing but unknown
|
||||||
## directory is ok to use.
|
## directory is ok to use.
|
||||||
cwd: string &default="/.";
|
cwd: string &default=".";
|
||||||
|
|
||||||
## Command that is currently waiting for a response.
|
## Command that is currently waiting for a response.
|
||||||
cmdarg: CmdArg &optional;
|
cmdarg: CmdArg &optional;
|
||||||
|
@ -172,7 +172,12 @@ function ftp_message(s: Info)
|
||||||
|
|
||||||
local arg = s$cmdarg$arg;
|
local arg = s$cmdarg$arg;
|
||||||
if ( s$cmdarg$cmd in file_cmds )
|
if ( s$cmdarg$cmd in file_cmds )
|
||||||
arg = fmt("ftp://%s%s", addr_to_uri(s$id$resp_h), build_path_compressed(s$cwd, arg));
|
{
|
||||||
|
local comp_path = build_path_compressed(s$cwd, arg);
|
||||||
|
if ( s$cwd[0] != "/" )
|
||||||
|
comp_path = cat("/", comp_path);
|
||||||
|
arg = fmt("ftp://%s%s", addr_to_uri(s$id$resp_h), comp_path);
|
||||||
|
}
|
||||||
|
|
||||||
s$ts=s$cmdarg$ts;
|
s$ts=s$cmdarg$ts;
|
||||||
s$command=s$cmdarg$cmd;
|
s$command=s$cmdarg$cmd;
|
||||||
|
|
|
@ -19,7 +19,7 @@ function extract_path(input: string): string
|
||||||
}
|
}
|
||||||
|
|
||||||
## Compresses a given path by removing '..'s and the parent directory it
|
## Compresses a given path by removing '..'s and the parent directory it
|
||||||
## references and also removing '/'s.
|
## references and also removing dual '/'s and extraneous '/./'s.
|
||||||
## dir: a path string, either relative or absolute
|
## dir: a path string, either relative or absolute
|
||||||
## Returns: a compressed version of the input path
|
## Returns: a compressed version of the input path
|
||||||
function compress_path(dir: string): string
|
function compress_path(dir: string): string
|
||||||
|
@ -41,7 +41,7 @@ function compress_path(dir: string): string
|
||||||
return compress_path(dir);
|
return compress_path(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
const multislash_sep = /(\/){2,}/;
|
const multislash_sep = /(\/\.?){2,}/;
|
||||||
parts = split_all(dir, multislash_sep);
|
parts = split_all(dir, multislash_sep);
|
||||||
for ( i in parts )
|
for ( i in parts )
|
||||||
if ( i % 2 == 0 )
|
if ( i % 2 == 0 )
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
##! Log the loaded scripts.
|
##! Log the loaded scripts.
|
||||||
|
@load base/utils/paths
|
||||||
|
|
||||||
module LoadedScripts;
|
module LoadedScripts;
|
||||||
|
|
||||||
|
@ -34,5 +35,5 @@ event bro_init() &priority=5
|
||||||
|
|
||||||
event bro_script_loaded(path: string, level: count)
|
event bro_script_loaded(path: string, level: count)
|
||||||
{
|
{
|
||||||
Log::write(LoadedScripts::LOG, [$name=cat(depth[level], path)]);
|
Log::write(LoadedScripts::LOG, [$name=cat(depth[level], compress_path(path))]);
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue