Goto main content

realpath

Check is a file is valid.

REALPATH

NAME

realpath - Checks is a file is valid.

SYNOPSIS

realpath([error:variable:]"file");

DESCRIPTION

This function is used to check the validity of a file.

If the path of the file leads outside of the root of the website, it returns false.

If "error" is set, the following variables are also returned:

errcode : error code,
errmsg : error message,
path : normalize path of file,
realpath : normaize real path of file.

EXAMPLES

Note: In the followings examples, the _ between the { should be removed to make it work.

res={_{ realpath(1,2); }}. return .*One file must be specified.*
res={_{ realpath("../../../etc/passwd"); }}. return res=false.
res={_{ realpath(error:a,"../../../etc/passwd"); a;}}. return .*The given path was above the root path.*
res={_{ realpath(error:a,"../../html/passwd"); ";"; a.errmsg;}}. return res=true;.
res={_{ realpath(error:a,"../../html/passwd"); a.errcode;}}. return res=true0.
res={_{ realpath(error:a,"../../html/passwd"); a.path;}}. return res=true/html/passwd.
res={_{ realpath(error:a,"../../html/passwd"); a.realpath;}}. return res=true/usr/local/website/v5/html/passwd.

SEE ALSO

{{ include("includes/files.sn") }}

AUTHOR

Written by Pierre Laplante and Caroline Laplante, <laplante@sednove.com>

MODIFICATIONS

1.0 2014-09-09 21:24:14 laplante@sednove.com

Edit

© 2024 extenso Inc. All rights reserved.