diff options
author | andrew <andrew@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2010-07-17 03:33:28 +0000 |
---|---|---|
committer | andrew <andrew@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2010-07-17 03:33:28 +0000 |
commit | 0dd34872d41e7e651565e099e1b81440b11ebca5 (patch) | |
tree | 1c64722e7c25c4bec601d9296e5d9edfaa08a7af /packages/chm | |
parent | 605c7bbfbddd267b2cbfe9357856adf0116f92cc (diff) | |
download | fpc-0dd34872d41e7e651565e099e1b81440b11ebca5.tar.gz |
* fixed bug 15838 where chm urls might have a backslash in the url
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@15592 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/chm')
-rw-r--r-- | packages/chm/src/chmreader.pas | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/packages/chm/src/chmreader.pas b/packages/chm/src/chmreader.pas index db0a3f5e4b..2c3d4d1a89 100644 --- a/packages/chm/src/chmreader.pas +++ b/packages/chm/src/chmreader.pas @@ -268,15 +268,18 @@ end; procedure TChmReader.ReadCommonData; // A little helper proc to make reading a null terminated string easier - function ReadString(const Stream: TStream): String; + function ReadString(const Stream: TStream; StartPos: DWord; FixURL: Boolean): String; var buf: array[0..49] of char; begin Result := ''; + Stream.Position := StartPos; repeat Stream.Read(buf, 50); Result := Result + buf; until Pos(#0, buf) > -1; + if FixURL then + Result := StringReplace(Result, '\', '/', [rfReplaceAll]); end; procedure ReadFromSystem; var @@ -373,7 +376,6 @@ procedure TChmReader.ReadCommonData; EntryCount, EntrySize: DWord; EntryStart: QWord; - StrPosition: DWord; X: Integer; OffSet: QWord; begin @@ -399,27 +401,19 @@ procedure TChmReader.ReadCommonData; EntryStart := OffSet + (X*EntrySize); if fTitle = '' then begin fWindows.Position := EntryStart + $14; - StrPosition := LEtoN(fWindows.ReadDWord); - fStrings.Position := StrPosition; - fTitle := '/'+ReadString(fStrings); + fTitle := '/'+ReadString(fStrings, LEtoN(fWindows.ReadDWord), False); end; if fTOCFile = '' then begin fWindows.Position := EntryStart + $60; - StrPosition := LEtoN(fWindows.ReadDWord); - fStrings.Position := StrPosition; - fTOCFile := '/'+ReadString(fStrings); + fTOCFile := '/'+ReadString(fStrings, LEtoN(fWindows.ReadDWord), True); end; if fIndexFile = '' then begin fWindows.Position := EntryStart + $64; - StrPosition := LEtoN(fWindows.ReadDWord); - fStrings.Position := StrPosition; - fIndexFile := '/'+ReadString(fStrings); + fIndexFile := '/'+ReadString(fStrings, LEtoN(fWindows.ReadDWord), True); end; if fDefaultPage = '' then begin fWindows.Position := EntryStart + $68; - StrPosition := LEtoN(fWindows.ReadDWord); - fStrings.Position := StrPosition; - fDefaultPage := '/'+ReadString(fStrings); + fDefaultPage := '/'+ReadString(fStrings, LEtoN(fWindows.ReadDWord), True); end; end; ReadWindows(FWindows); @@ -445,8 +439,7 @@ procedure TChmReader.ReadCommonData; while fIVB.Position < fIVB.Size do begin Value := LEtoN(fIVB.ReadDWord); OffSet := LEtoN(fIVB.ReadDWord); - fStrings.Position := Offset; - Str := '/'+ReadString(fStrings); + Str := '/'+ ReadString(fStrings, Offset, True); fContextList.AddContext(Value, Str); end; end; |