[patch_done] passwords with ; in them
Posted: 03.03.2012, 13:17
one of our databases has a db-account that has a ; in the password (I am not the DBA and can not change this password)
As ; is used as a separator to pass information between the zeos objects, the password gets truncated at the ; sign.
To solve this, I have changed some code in zsysutils.pas (revision 1039):
(change = translate ; to \; when building the string, and translate \; back to ; when using it)
1. rewritten the FirstDelimiter function :
2. modified the SplitToStringList procedure
2a. changed "List.Add(Copy(Str, 1, DelimPos - 1));" to
2b. changed "List.Add(Str);" to
As ; is used as a separator to pass information between the zeos objects, the password gets truncated at the ; sign.
To solve this, I have changed some code in zsysutils.pas (revision 1039):
(change = translate ; to \; when building the string, and translate \; back to ; when using it)
1. rewritten the FirstDelimiter function :
Code: Select all
function FirstDelimiter(const Delimiters, Str: string): Integer;
var I, Index, j: Integer;
d : Char;
begin
Result := 0;
for I := 1 to Length(Delimiters) do begin
d := Delimiters[I];
if (d = ';') and (Pos('\;', Str) > 0) then begin
for j := 1 to Length(Str) do
if Str[j] = ';' then begin
if (j > 1) and (Str[j-1] = '\') then Continue;
Index := j;
Result := Index;
Break;
end;
end else begin
Index := Pos(d, Str);
if (Index > 0) and ((Index < Result) or (Result = 0)) then
Result := Index;
end;
end;
end;
2a. changed "List.Add(Copy(Str, 1, DelimPos - 1));" to
Code: Select all
List.Add(StringReplace(Copy(Str, 1, DelimPos - 1), '\;', ';', [rfReplaceAll]));
Code: Select all
List.Add(StringReplace(Str, '\;', ';', [rfReplaceAll]));