mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2024-11-16 00:05:55 +01:00
CustomAbsolutePath canonicalizes relative and absolute paths now.
Added CustomPathIsURL and CustomPathIsUNC functions Added checks in CustomPathCanonicalize to avoid buffer overruns and unsupported paths.
This commit is contained in:
parent
09685f56e1
commit
8ec0801777
@ -128,6 +128,10 @@ function PathIsRelativeUnicode(pszPath: LPCWSTR): BOOL; stdcall; external SHLWAP
|
|||||||
function GetGlobalMemoryStatusEx(var Buffer: TMyMemoryStatusEx): BOOL; stdcall; external Kernel32DLL name 'GlobalMemoryStatusEx';
|
function GetGlobalMemoryStatusEx(var Buffer: TMyMemoryStatusEx): BOOL; stdcall; external Kernel32DLL name 'GlobalMemoryStatusEx';
|
||||||
function PathCanonicalizeAnsi(pszBuf: LPSTR; pszPath: LPCSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathCanonicalizeA';
|
function PathCanonicalizeAnsi(pszBuf: LPSTR; pszPath: LPCSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathCanonicalizeA';
|
||||||
function PathCanonicalizeUnicode(pszBuf: LPWSTR; pszPath: LPCWSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathCanonicalizeW';
|
function PathCanonicalizeUnicode(pszBuf: LPWSTR; pszPath: LPCWSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathCanonicalizeW';
|
||||||
|
function PathIsUNCAnsi(pszPath: LPCWSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathIsUNCA';
|
||||||
|
function PathIsUNCUnicode(pszPath: LPCWSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathIsUNCW';
|
||||||
|
function PathIsURLAnsi(pszPath: LPCWSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathIsURLA';
|
||||||
|
function PathIsURLUnicode(pszPath: LPCWSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathIsURLW';
|
||||||
|
|
||||||
{$IFNDEF DELPHI12_UP}
|
{$IFNDEF DELPHI12_UP}
|
||||||
{$IFDEF WIN64}
|
{$IFDEF WIN64}
|
||||||
@ -142,6 +146,8 @@ function PathCanonicalizeUnicode(pszBuf: LPWSTR; pszPath: LPCWSTR): BOOL; stdcal
|
|||||||
function CustomPathIsRelative(const aPath : string) : boolean;
|
function CustomPathIsRelative(const aPath : string) : boolean;
|
||||||
function CustomPathCanonicalize(const aOriginalPath : string; var aCanonicalPath : string) : boolean;
|
function CustomPathCanonicalize(const aOriginalPath : string; var aCanonicalPath : string) : boolean;
|
||||||
function CustomAbsolutePath(const aPath : string; aMustExist : boolean = False) : string;
|
function CustomAbsolutePath(const aPath : string; aMustExist : boolean = False) : string;
|
||||||
|
function CustomPathIsURL(const aPath : string) : boolean;
|
||||||
|
function CustomPathIsUNC(const aPath : string) : boolean;
|
||||||
function GetModulePath : string;
|
function GetModulePath : string;
|
||||||
|
|
||||||
function CefIsCertStatusError(Status : TCefCertStatus) : boolean;
|
function CefIsCertStatusError(Status : TCefCertStatus) : boolean;
|
||||||
@ -1419,6 +1425,32 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function CustomPathIsURL(const aPath : string) : boolean;
|
||||||
|
begin
|
||||||
|
{$IFDEF MSWINDOWS}
|
||||||
|
{$IFDEF DELPHI12_UP}
|
||||||
|
Result := PathIsURLUnicode(PChar(aPath + #0));
|
||||||
|
{$ELSE}
|
||||||
|
Result := PathIsURLAnsi(PChar(aPath + #0));
|
||||||
|
{$ENDIF}
|
||||||
|
{$ELSE}
|
||||||
|
Result := False;
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
|
function CustomPathIsUNC(const aPath : string) : boolean;
|
||||||
|
begin
|
||||||
|
{$IFDEF MSWINDOWS}
|
||||||
|
{$IFDEF DELPHI12_UP}
|
||||||
|
Result := PathIsUNCUnicode(PChar(aPath + #0));
|
||||||
|
{$ELSE}
|
||||||
|
Result := PathIsUNCAnsi(PChar(aPath + #0));
|
||||||
|
{$ENDIF}
|
||||||
|
{$ELSE}
|
||||||
|
Result := False;
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
function CustomPathCanonicalize(const aOriginalPath : string; var aCanonicalPath : string) : boolean;
|
function CustomPathCanonicalize(const aOriginalPath : string; var aCanonicalPath : string) : boolean;
|
||||||
var
|
var
|
||||||
TempBuffer: array [0..pred(MAX_PATH)] of Char;
|
TempBuffer: array [0..pred(MAX_PATH)] of Char;
|
||||||
@ -1426,17 +1458,22 @@ begin
|
|||||||
Result := False;
|
Result := False;
|
||||||
aCanonicalPath := '';
|
aCanonicalPath := '';
|
||||||
|
|
||||||
|
if (length(aOriginalPath) > MAX_PATH) or
|
||||||
|
(Copy(aOriginalPath, 1, 4) = '\\?\') or
|
||||||
|
CustomPathIsUNC(aOriginalPath) then
|
||||||
|
exit;
|
||||||
|
|
||||||
FillChar(TempBuffer, MAX_PATH * SizeOf(Char), 0);
|
FillChar(TempBuffer, MAX_PATH * SizeOf(Char), 0);
|
||||||
|
|
||||||
{$IFDEF MSWINDOWS}
|
{$IFDEF MSWINDOWS}
|
||||||
{$IFDEF DELPHI12_UP}
|
{$IFDEF DELPHI12_UP}
|
||||||
if PathCanonicalizeUnicode(@TempBuffer[0], PChar(aOriginalPath)) then
|
if PathCanonicalizeUnicode(@TempBuffer[0], PChar(aOriginalPath + #0)) then
|
||||||
begin
|
begin
|
||||||
aCanonicalPath := TempBuffer;
|
aCanonicalPath := TempBuffer;
|
||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
if PathCanonicalizeAnsi(@TempBuffer[0], PChar(aOriginalPath)) then
|
if PathCanonicalizeAnsi(@TempBuffer[0], PChar(aOriginalPath + #0)) then
|
||||||
begin
|
begin
|
||||||
aCanonicalPath := TempBuffer;
|
aCanonicalPath := TempBuffer;
|
||||||
Result := True;
|
Result := True;
|
||||||
@ -1451,7 +1488,13 @@ var
|
|||||||
begin
|
begin
|
||||||
if (length(aPath) > 0) then
|
if (length(aPath) > 0) then
|
||||||
begin
|
begin
|
||||||
if not(CustomPathIsRelative(aPath) and CustomPathCanonicalize(GetModulePath + aPath, TempPath)) then
|
if CustomPathIsRelative(aPath) then
|
||||||
|
begin
|
||||||
|
if not(CustomPathCanonicalize(GetModulePath + aPath, TempPath)) then
|
||||||
|
TempPath := aPath;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if not(CustomPathCanonicalize(aPath, TempPath)) then
|
||||||
TempPath := aPath;
|
TempPath := aPath;
|
||||||
|
|
||||||
if aMustExist and not(DirectoryExists(TempPath)) then
|
if aMustExist and not(DirectoryExists(TempPath)) then
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"UpdateLazPackages" : [
|
"UpdateLazPackages" : [
|
||||||
{
|
{
|
||||||
"ForceNotify" : true,
|
"ForceNotify" : true,
|
||||||
"InternalVersion" : 31,
|
"InternalVersion" : 32,
|
||||||
"Name" : "cef4delphi_lazarus.lpk",
|
"Name" : "cef4delphi_lazarus.lpk",
|
||||||
"Version" : "76.1.13.0"
|
"Version" : "76.1.13.0"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user