diff --git a/classesLib.pas b/classesLib.pas index f93c6bd..c815dd5 100644 --- a/classesLib.pas +++ b/classesLib.pas @@ -145,14 +145,12 @@ type last: record section:string; idx:integer; end; // cache for getIdx() fileExts: TStringDynArray; strTable: THashedStringList; - fUTF8: boolean; fOver: Ttpl; function getIdx(section:string):integer; function getTxt(section:string):string; function newSection(section:string):PtplSection; procedure fromString(txt:string); procedure setOver(v:Ttpl); - procedure updateUTF8(); public onChange: TNotifyEvent; sections: array of TtplSection; @@ -160,7 +158,6 @@ type destructor Destroy; override; property txt[section:string]:string read getTxt; default; property fullText:string read src write fromString; - property utf8:boolean read fUTF8; property over:Ttpl read fOver write setOver; function sectionExist(section:string):boolean; function getTxtByExt(fileExt:string):string; @@ -1109,7 +1106,6 @@ first:=TRUE; ptxt:=succ(ansiStrPos(bos, #10)); // get to the end of line (and then beyond) first:=FALSE; until ptxt = NIL; -updateUTF8(); if assigned(onChange) then onChange(self); end; // appendString @@ -1117,12 +1113,8 @@ end; // appendString procedure Ttpl.setOver(v:Ttpl); begin fOver:=v; -updateUTF8(); end; // setOver -procedure Ttpl.updateUTF8(); -begin fUTF8:=assigned(over) and over.utf8 or utf8test(fullText) end; - function Ttpl.getSections():TStringDynArray; var i: integer; diff --git a/default.tpl b/default.tpl index d4610e1..f4659a5 100644 --- a/default.tpl +++ b/default.tpl @@ -494,7 +494,7 @@ z-index:1; /* without this .item-menu will be over*/ } "speed":"%smart-speed%" }, {.if| {.length|%user%.} |{: - {.set item|{.force ansi|%folder%%item-name%.}|comment={.!uploaded by.} %user%.} + {.set item|%folder%%item-name%|comment={.!uploaded by.} %user%.} :}.} [upload-failed] @@ -534,7 +534,7 @@ z-index:1; /* without this .item-menu will be over*/ } {.set|x|{.postvar|name.}.} {.break|if={.pos|\|var=x.}{.pos|/|var=x.}|result=forbidden.} {.break|if={.not|{.can mkdir.}.}|result=not authorized.} -{.set|x|{.force ansi|%folder%{.^x.}.}.} +{.set|x|%folder%{.^x.}.} {.break|if={.exists|{.^x.}.}|result=exists.} {.break|if={.not|{.length|{.mkdir|{.^x.}.}.}.}|result=failed.} {.add to log|{.!User.} %user% {.!created folder.} "{.^x.}".} @@ -545,9 +545,9 @@ z-index:1; /* without this .item-menu will be over*/ } {.break|if={.not|{.can rename.}.}|result=forbidden.} {.break|if={.is file protected|{.postvar|from.}.}|result=forbidden.} {.break|if={.is file protected|{.postvar|to.}.}|result=forbidden.} -{.set|x|{.force ansi|%folder%{.postvar|from.}.}.} -{.set|yn|{.force ansi|{.postvar|to.}.}.} -{.set|y|{.force ansi|%folder%.}{.^yn.}.} +{.set|x|%folder%{.postvar|from.}.} +{.set|yn|{.postvar|to.}.} +{.set|y|%folder%{.^yn.}.} {.break|if={.not|{.exists|{.^x.}.}.}|result=not found.} {.break|if={.exists|{.^y.}.}|result=exists.} {.set|comment| {.get item|{.^x.}|comment.} .} @@ -561,12 +561,12 @@ z-index:1; /* without this .item-menu will be over*/ } [ajax.move|no log] {.check session.} -{.set|dst|{.force ansi|{.postvar|dst.}.}.} +{.set|dst|{.postvar|dst.}.} {.break|if={.not|{.and|{.can move.}|{.get|can delete.}|{.get|can upload|path={.^dst.}.}/and.}.} |result=forbidden.} {.set|log|{.!Moving items to.} {.^dst.}.} -{.for each|fn|{.replace|:|{.no pipe||.}|{.force ansi|{.postvar|files.}.}.}|{: +{.for each|fn|{.replace|:|{.no pipe||.}|{.postvar|files.}.}|{: {.break|if={.is file protected|var=fn.}|result=forbidden.} - {.set|x|{.force ansi|%folder%.}{.^fn.}.} + {.set|x|%folder%{.^fn.}.} {.set|y|{.^dst.}/{.^fn.}.} {.if not |{.exists|{.^x.}.}|{.^x.}: {.!not found.}|{: {.if|{.exists|{.^y.}.}|{.^y.}: {.!already exists.}|{: @@ -578,7 +578,7 @@ z-index:1; /* without this .item-menu will be over*/ } {.set item|{.^y.}|comment={.^comment.}.} :} | {: {.set|log|{.chr|13.}{.^fn.} (failed)|mode=append.} - {.maybe utf8|{.^fn.}.}: {.!not moved.} + {.^fn.}: {.!not moved.} :}/if.} :}/if.} :}.} @@ -591,14 +591,14 @@ z-index:1; /* without this .item-menu will be over*/ } {.break|if={.not|{.can comment.}.} |result=forbidden.} {.for each|fn|{.replace|:|{.no pipe||.}|{.postvar|files.}.}|{: {.break|if={.is file protected|var=fn.}|result=forbidden.} - {.set item|{.force ansi|%folder%{.^fn.}.}|comment={.force ansi|{.postvar|text.}.}.} + {.set item|%folder%{.^fn.}|comment={.postvar|text.}.} :}.} {.pipe|ok.} [ajax.changepwd|no log] {.check session.} {.break|if={.not|{.can change pwd.}.} |result=forbidden.} -{.if|{.length|{.set account||password={.force ansi|{.postvar|new.}.}.}/length.}|ok|failed.} +{.if|{.length|{.set account||password={.postvar|new.}.}/length.}|ok|failed.} [special:alias] check session=if|{.{.cookie|HFS_SID_.} != {.postvar|token.}.}|{:{.cookie|HFS_SID_|value=|expires=-1.} {.break|result=bad session.}:} diff --git a/main.pas b/main.pas index 36c2619..4684721 100644 --- a/main.pas +++ b/main.pas @@ -1335,7 +1335,7 @@ function loadDescriptionFile(fn:string):string; begin result:=loadTextFile(fn); if result = '' then - result:=loadTextFile(fn+'\descript.ion'); + result:=loadTextFile(fn+'\'+DESCRIPT_ION); if (result > '') and mainfrm.oemForIonChk.checked then OEMToCharBuff(@result[1], @result[1], length(result)); //to test end; // loadDescriptionFile diff --git a/utillib.pas b/utillib.pas index ffba5ba..b24c908 100644 --- a/utillib.pas +++ b/utillib.pas @@ -215,8 +215,6 @@ function getTill(ss, s:string; included:boolean=FALSE):string; overload; function getTill(i:integer; s:string):string; overload; function singleLine(s:string):boolean; function poss(chars:TcharSet; s:string; ofs:integer=1):integer; -function optAnsi(bool:boolean; s:string):string; -function utf8Test(s:string):boolean; function jsEncode(s, chars:string):string; function nonEmptyConcat(pre,s:string; post:string=''):string; function first(a,b:integer):integer; overload; @@ -933,7 +931,9 @@ end; function loadTextFile(fn:string):string; begin try result:=IOUtils.TFile.ReadAllText(fn) -except result:='' end +except result:='' end; +try result:=UTF8decode(result) +except end; end; function loadFile(fn:string; from:int64=0; size:int64=-1):ansistring; @@ -2043,9 +2043,6 @@ setLength(result, 1000); setLength(result, getTempPath(length(result), @result[1])); end; // getTempDir -function optAnsi(bool:boolean; s:string):string; -begin if bool then result:=UTF8toAnsi(s) else result:=s end; - function blend(from,to_:Tcolor; perc:real):Tcolor; var i: integer; @@ -2083,9 +2080,6 @@ end; // jsEncode function holdingKey(key:integer):boolean; begin result:=getAsyncKeyState(key) and $8000 <> 0 end; -function utf8Test(s:string):boolean; -begin result:=ansiContainsText(s, 'charset=UTF-8') end; - // concat pre+s+post only if s is non empty function nonEmptyConcat(pre, s:string; post:string=''):string; begin if s = '' then result:='' else result:=pre+s+post end; @@ -2414,7 +2408,7 @@ l:=length(s); while i <= l do begin p:=posEx('&',s,i); - t:=decodeURL(replaceStr(substr(s,i,if_(p=0,0,p-1)), '+',' '), FALSE); // TODO should we instead try to decode utf-8? doing so may affect calls to {.force ansi.} in the template + t:=decodeURL(replaceStr(substr(s,i,if_(p=0,0,p-1)), '+',' ')); // TODO should we instead try to decode utf-8? doing so may affect calls to {.force ansi.} in the template sl.add(t); if p = 0 then exit; i:=p+1;