mirror of
https://github.com/rejetto/hfs2.git
synced 2025-12-19 10:03:56 +01:00
fix: account notes not loaded correctly
This commit is contained in:
parent
d0ca00e037
commit
4c8eed1fa8
@ -444,6 +444,7 @@ begin
|
|||||||
until false;
|
until false;
|
||||||
end; // nonQuotedPos
|
end; // nonQuotedPos
|
||||||
|
|
||||||
|
// consider using TBase64Encoding.Base64.Encode() in unit netencoding
|
||||||
function base64encode(s:ansistring):ansistring;
|
function base64encode(s:ansistring):ansistring;
|
||||||
const
|
const
|
||||||
TABLE='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
TABLE='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
||||||
@ -482,9 +483,9 @@ i:=1;
|
|||||||
while i <= length(s) do
|
while i <= length(s) do
|
||||||
begin
|
begin
|
||||||
result:=result
|
result:=result
|
||||||
+chr(TABLE[s[i]] shl 2+TABLE[s[i+1]] shr 4)
|
+ansichar(TABLE[s[i]] shl 2+TABLE[s[i+1]] shr 4)
|
||||||
+ifThen(s[i+2]<>'=', chr(TABLE[s[i+1]] shl 4+TABLE[s[i+2]] shr 2))
|
+ifThen(s[i+2]<>'=', ansichar(TABLE[s[i+1]] shl 4+TABLE[s[i+2]] shr 2))
|
||||||
+ifThen(s[i+3]<>'=', chr(TABLE[s[i+2]] shl 6+TABLE[s[i+3]]));
|
+ifThen(s[i+3]<>'=', ansichar(TABLE[s[i+2]] shl 6+TABLE[s[i+3]]));
|
||||||
inc(i,4);
|
inc(i,4);
|
||||||
end;
|
end;
|
||||||
end; // base64decode
|
end; // base64decode
|
||||||
|
|||||||
108
main.pas
108
main.pas
@ -26,11 +26,11 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
// delphi libs
|
// delphi libs
|
||||||
zlib, Windows, Messages, SysUtils, Forms, Menus, Graphics, Controls, ComCtrls, Dialogs, math,
|
Windows, Messages, SysUtils, Forms, Menus, Graphics, Controls, ComCtrls, Dialogs, math,
|
||||||
registry, ExtCtrls, shellapi, ImgList, ToolWin, StdCtrls, strutils, AppEvnts, types,
|
registry, ExtCtrls, shellapi, ImgList, ToolWin, StdCtrls, strutils, AppEvnts, types,
|
||||||
winsock, clipbrd, shlobj, activex, Buttons, FileCtrl, dateutils, iniFiles, Classes,
|
winsock, clipbrd, shlobj, activex, Buttons, FileCtrl, dateutils, iniFiles, Classes,
|
||||||
// 3rd part libs. ensure you have all of these, the same version reported in dev-notes.txt
|
// 3rd part libs. ensure you have all of these, the same version reported in dev-notes.txt
|
||||||
OverbyteIcsWSocket, OverbyteIcsHttpProt, OverbyteicsMD5, GIFimage, regexpr,
|
OverbyteIcsWSocket, OverbyteIcsHttpProt, OverbyteicsMD5, GIFimage, regexpr, OverbyteIcsZLibHigh, OverbyteIcsZLibObj,
|
||||||
// rejetto libs
|
// rejetto libs
|
||||||
HSlib, traylib, monoLib, progFrmLib, classesLib, System.ImageList;
|
HSlib, traylib, monoLib, progFrmLib, classesLib, System.ImageList;
|
||||||
|
|
||||||
@ -1086,7 +1086,7 @@ var
|
|||||||
clock: integer; // program ticks (tenths of second)
|
clock: integer; // program ticks (tenths of second)
|
||||||
// workaround for splitters' bad behaviour
|
// workaround for splitters' bad behaviour
|
||||||
lastGoodLogWidth, lastGoodConnHeight: integer;
|
lastGoodLogWidth, lastGoodConnHeight: integer;
|
||||||
etags: THashedStringList;
|
etags: THashedStringList;
|
||||||
tray_ico: Ticon; // the actual icon shown in tray
|
tray_ico: Ticon; // the actual icon shown in tray
|
||||||
usingFreePort: boolean=TRUE; // the actual server port set was 0
|
usingFreePort: boolean=TRUE; // the actual server port set was 0
|
||||||
upTime: Tdatetime; // the server is up since...
|
upTime: Tdatetime; // the server is up since...
|
||||||
@ -1236,11 +1236,6 @@ begin
|
|||||||
result:=mainfrm.fingerprintsChk.checked and isExtension(fn, '.md5')
|
result:=mainfrm.fingerprintsChk.checked and isExtension(fn, '.md5')
|
||||||
end; // isFingerprintFile
|
end; // isFingerprintFile
|
||||||
|
|
||||||
function zCompressStr2(s:string; lev:TZCompressionLevel):ansistring;
|
|
||||||
begin
|
|
||||||
result:=PansiChar(zcompressStr(s,lev))^
|
|
||||||
end;
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TaccountRecursionStopCase = (ARSC_REDIR, ARSC_NOLIMITS, ARSC_IN_SET);
|
TaccountRecursionStopCase = (ARSC_REDIR, ARSC_NOLIMITS, ARSC_IN_SET);
|
||||||
|
|
||||||
@ -4061,7 +4056,7 @@ if mainfrm.useISOdateChk.checked then FormatSettings.ShortDateFormat:='yyyy-mm-d
|
|||||||
else FormatSettings.ShortDateFormat:=GetLocaleStr(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE,'');
|
else FormatSettings.ShortDateFormat:=GetLocaleStr(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE,'');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure Tmainfrm.add2log(lines:string; cd:TconnData=NIL; clr:Tcolor=clDefault);
|
procedure Tmainfrm.add2log(lines:string; cd:TconnData=NIL; clr:Tcolor=Graphics.clDefault);
|
||||||
var
|
var
|
||||||
s, ts, first, rest, addr: string;
|
s, ts, first, rest, addr: string;
|
||||||
begin
|
begin
|
||||||
@ -4069,7 +4064,7 @@ if not logOnVideoChk.checked
|
|||||||
and ((logFile.filename = '') or (logFile.apacheFormat > '')) then
|
and ((logFile.filename = '') or (logFile.apacheFormat > '')) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
if clr = clDefault then
|
if clr = Graphics.clDefault then
|
||||||
clr:=clWindowText;
|
clr:=clWindowText;
|
||||||
|
|
||||||
if logDateChk.checked then
|
if logDateChk.checked then
|
||||||
@ -6304,6 +6299,46 @@ port:=was;
|
|||||||
if act then startServer();
|
if act then startServer();
|
||||||
end; // changePort
|
end; // changePort
|
||||||
|
|
||||||
|
function zCompressStr(const s: ansistring; level:TCompressionLevel=clMax; type_:TzStreamType=zsZlib): ansistring;
|
||||||
|
var
|
||||||
|
src, dst: TMemoryStream;
|
||||||
|
begin
|
||||||
|
if s = '' then
|
||||||
|
exit('');
|
||||||
|
src:= TMemoryStream.create;
|
||||||
|
dst:= TMemoryStream.create;
|
||||||
|
try
|
||||||
|
src.write(s[1], Length(s));
|
||||||
|
src.position:= 0;
|
||||||
|
zlibCompressStreamEx(src, dst, level, type_, false);
|
||||||
|
setLength(result, dst.size);
|
||||||
|
copyMemory(@result[1], dst.Memory, dst.Size);
|
||||||
|
finally
|
||||||
|
src.free;
|
||||||
|
dst.free;
|
||||||
|
end;
|
||||||
|
end; // zCompressStr
|
||||||
|
|
||||||
|
function zDecompressStr(const s: ansistring): ansistring;
|
||||||
|
var
|
||||||
|
src, dst: TMemoryStream;
|
||||||
|
begin
|
||||||
|
if s = '' then
|
||||||
|
exit('');
|
||||||
|
src:= TMemoryStream.create;
|
||||||
|
dst:= TMemoryStream.create;
|
||||||
|
try
|
||||||
|
src.write(s[1], Length(s));
|
||||||
|
src.position:= 0;
|
||||||
|
zlibDecompressStream(src, dst);
|
||||||
|
setLength(result, dst.size);
|
||||||
|
copyMemory(@result[1], dst.Memory, dst.Size);
|
||||||
|
finally
|
||||||
|
src.free;
|
||||||
|
dst.free;
|
||||||
|
end;
|
||||||
|
end; // zDecompressIcs
|
||||||
|
|
||||||
function TmainFrm.getCfg(exclude:string=''):string;
|
function TmainFrm.getCfg(exclude:string=''):string;
|
||||||
type
|
type
|
||||||
Tencoding=(E_PLAIN,E_B64,E_ZIP);
|
Tencoding=(E_PLAIN,E_B64,E_ZIP);
|
||||||
@ -6315,8 +6350,8 @@ type
|
|||||||
E_B64: result:=base64encode(s);
|
E_B64: result:=base64encode(s);
|
||||||
E_ZIP:
|
E_ZIP:
|
||||||
begin
|
begin
|
||||||
result:=zCompressStr2(s, zcMax);
|
result:=zCompressStr(s, clMax);
|
||||||
if length(result) > round(0.95*length(s)) then
|
if length(result) > round(0.9*length(s)) then
|
||||||
result:=s;
|
result:=s;
|
||||||
result:=base64encode(result);
|
result:=base64encode(result);
|
||||||
end;
|
end;
|
||||||
@ -6633,16 +6668,12 @@ var
|
|||||||
end;
|
end;
|
||||||
end; // loadBanlist
|
end; // loadBanlist
|
||||||
|
|
||||||
function unzip(s:ansistring):ansistring;
|
function unzipCfgProp(s:ansistring):ansistring;
|
||||||
var a: Tbytes;
|
|
||||||
begin
|
begin
|
||||||
try
|
result:=base64decode(s);
|
||||||
s:=base64decode(s);
|
try result:=ZDecompressStr(result)
|
||||||
setLength(a, length(s));
|
|
||||||
move(s[1], a[0], length(s));
|
|
||||||
result:=ZDecompressStr(a)
|
|
||||||
except end;
|
except end;
|
||||||
end; // unzip
|
end; // unzipCfgProp
|
||||||
|
|
||||||
procedure strToAccounts();
|
procedure strToAccounts();
|
||||||
var
|
var
|
||||||
@ -6665,20 +6696,27 @@ var
|
|||||||
// account properties are separated by pipes
|
// account properties are separated by pipes
|
||||||
t:=chop('|',s);
|
t:=chop('|',s);
|
||||||
p:=chop(':',t); // get property name
|
p:=chop(':',t); // get property name
|
||||||
if p = '' then continue;
|
if p = '' then
|
||||||
|
continue;
|
||||||
if p = 'login' then
|
if p = 'login' then
|
||||||
begin
|
begin
|
||||||
if not anycharIn(':', t) then
|
if not anycharIn(':', t) then
|
||||||
t:=base64decode(t);
|
t:=base64decode(t);
|
||||||
a.user:=chop(':',t);
|
a.user:=chop(':',t);
|
||||||
a.pwd:=t;
|
a.pwd:=t;
|
||||||
end;
|
end
|
||||||
if p = 'enabled' then a.enabled:=yes(t);
|
else if p = 'enabled' then
|
||||||
if p = 'no-limits' then a.noLimits:=yes(t);
|
a.enabled:=yes(t)
|
||||||
if p = 'group' then a.group:=yes(t);
|
else if p = 'no-limits' then
|
||||||
if p = 'redir' then a.redir:=t;
|
a.noLimits:=yes(t)
|
||||||
if p = 'link' then a.link:=split(':',t);
|
else if p = 'group' then
|
||||||
if p = 'notes' then a.notes:=unzip(t);
|
a.group:=yes(t)
|
||||||
|
else if p = 'redir' then
|
||||||
|
a.redir:=t
|
||||||
|
else if p = 'link' then
|
||||||
|
a.link:=split(':',t)
|
||||||
|
else if p = 'notes' then
|
||||||
|
a.notes:=UTF8ToString(unzipCfgProp(t))
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end; // strToAccounts
|
end; // strToAccounts
|
||||||
@ -6704,7 +6742,7 @@ var
|
|||||||
while l > '' do
|
while l > '' do
|
||||||
begin
|
begin
|
||||||
iFrom:=strTointDef(chop(':', l), -1);
|
iFrom:=strTointDef(chop(':', l), -1);
|
||||||
iTo:=str2pic(unzip(chop('|', l)));
|
iTo:=str2pic(unzipCfgProp(chop('|', l)));
|
||||||
for i:=0 to length(iconMasks)-1 do
|
for i:=0 to length(iconMasks)-1 do
|
||||||
if iconMasks[i].int = iFrom then
|
if iconMasks[i].int = iFrom then
|
||||||
iconMasks[i].int:=iTo;
|
iconMasks[i].int:=iTo;
|
||||||
@ -9281,10 +9319,10 @@ while not tlv.isOver() do
|
|||||||
{ Explanation for the #0 workaround.
|
{ Explanation for the #0 workaround.
|
||||||
{ I found an uncompressable vfs file, with ZDecompressStr2() raising an exception.
|
{ I found an uncompressable vfs file, with ZDecompressStr2() raising an exception.
|
||||||
{ In the end i found it was missing a trailing #0, maybe do to an incorrect handling of strings
|
{ In the end i found it was missing a trailing #0, maybe do to an incorrect handling of strings
|
||||||
{ containing a trailing #0. You know, being using a zlib wrapper there is some underlying C code.
|
{ containing a trailing #0. Using a zlib wrapper there is some underlying C code.
|
||||||
{ I was unable to reproduce the bug, but i found that correct data doesn't complain if i add an extra #0. }
|
{ I was unable to reproduce the bug, but i found that correct data doesn't complain if i add an extra #0. }
|
||||||
try
|
try
|
||||||
data:=ZDecompressStr(bytesOf(data+#0));
|
data:=ZDecompressStr(data+#0);
|
||||||
if isAnyMacroIn(data) then
|
if isAnyMacroIn(data) then
|
||||||
loadingVFS.macrosFound:=TRUE;
|
loadingVFS.macrosFound:=TRUE;
|
||||||
setVFS(data, node);
|
setVFS(data, node);
|
||||||
@ -9387,7 +9425,7 @@ function addVFSheader(vfsdata:ansistring):ansistring;
|
|||||||
begin
|
begin
|
||||||
if length(vfsdata) > COMPRESSION_THRESHOLD then
|
if length(vfsdata) > COMPRESSION_THRESHOLD then
|
||||||
vfsdata:=TLV(FK_COMPRESSED_ZLIB,
|
vfsdata:=TLV(FK_COMPRESSED_ZLIB,
|
||||||
ZcompressStr2(vfsdata, zcFastest) );
|
ZcompressStr(vfsdata, clFastest) );
|
||||||
result:= TLV(FK_HEAD, VFS_FILE_IDENTIFIER)
|
result:= TLV(FK_HEAD, VFS_FILE_IDENTIFIER)
|
||||||
+TLV(FK_FORMAT_VER, str_(CURRENT_VFS_FORMAT))
|
+TLV(FK_FORMAT_VER, str_(CURRENT_VFS_FORMAT))
|
||||||
+TLV(FK_HFS_VER, VERSION)
|
+TLV(FK_HFS_VER, VERSION)
|
||||||
@ -9469,7 +9507,7 @@ var
|
|||||||
|
|
||||||
function getColor(idx:integer; def:Tcolor):Tcolor;
|
function getColor(idx:integer; def:Tcolor):Tcolor;
|
||||||
begin
|
begin
|
||||||
if (length(colors) <= idx) or (colors[idx] = clDefault) then result:=def
|
if (length(colors) <= idx) or (colors[idx] = Graphics.clDefault) then result:=def
|
||||||
else result:=colors[idx]
|
else result:=colors[idx]
|
||||||
end; // getColor
|
end; // getColor
|
||||||
|
|
||||||
@ -9572,7 +9610,7 @@ else
|
|||||||
bmp.height:=min(i, 300000 div max(1,bmp.width));
|
bmp.height:=min(i, 300000 div max(1,bmp.width));
|
||||||
refresh:=ansistring(chop('x',options));
|
refresh:=ansistring(chop('x',options));
|
||||||
for i:=1 to 5 do
|
for i:=1 to 5 do
|
||||||
addColor(stringToColorEx(chop('x',options), clDefault));
|
addColor(stringToColorEx(chop('x',options), graphics.clDefault));
|
||||||
except
|
except
|
||||||
end;
|
end;
|
||||||
drawGraphOn(bmp.canvas, colors);
|
drawGraphOn(bmp.canvas, colors);
|
||||||
@ -10803,7 +10841,7 @@ if (cd.workaroundForIEutf8 = toDetect) and (cd.agent > '') then
|
|||||||
cd.workaroundForIEutf8:=yes
|
cd.workaroundForIEutf8:=yes
|
||||||
else
|
else
|
||||||
cd.workaroundForIEutf8:=no;
|
cd.workaroundForIEutf8:=no;
|
||||||
s:=ZcompressStr2(s, zcFastest);
|
s:=ZcompressStr(s, clFastest, zsGzip);
|
||||||
if (cd.workaroundForIEutf8 = yes) and (length(s) < BAD_IE_THRESHOLD) then exit;
|
if (cd.workaroundForIEutf8 = yes) and (length(s) < BAD_IE_THRESHOLD) then exit;
|
||||||
cd.conn.addHeader('Content-Encoding: gzip');
|
cd.conn.addHeader('Content-Encoding: gzip');
|
||||||
//cd.conn.addHeader('Content-Length: '+intToStr(length(s)));
|
//cd.conn.addHeader('Content-Length: '+intToStr(length(s)));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user