* * *

Author Topic: Non blocking bugs in chmcmd  (Read 250 times)

Mwoua

  • New member
  • *
  • Posts: 12
Non blocking bugs in chmcmd
« on: July 17, 2017, 10:50:47 pm »
Following this thread : You can find attached a sample project (I made it as small as possible) with two bugs :

-internet links are reported as missing file :
Code: Pascal  [Select]
  1. Warning: Found file https://github.com/philsquared/Catch/blob/master/docs/Readme.md while scanning _l_u_t_sensor_leddar_vu8_modbus_8cpp.html, but couldn't find it on disk


-Existing anchors in html are reported as missing (and maybe it should just be a warning)
Code: Pascal  [Select]
  1. Error: Anchor _l_u_t_sensor_leddar_vu8_modbus_8cpp_a0058abed3f064d06890a5aa1c1c6fb6d.html#a0058abed3f064d06890a5aa1c1c6fb6d undefined; first use _l_u_t_sensor_leddar_vu8_modbus_8cpp.html

wp

  • Hero Member
  • *****
  • Posts: 3600
Re: Non blocking bugs in chmcmd
« Reply #1 on: July 17, 2017, 11:28:10 pm »
I found the bug leading to the missing internet links error: All these links have the https protocol. chmfilewriter contains a list protocols to be ignored, and https is missing here. After adding it here, the warning is gone.

This list is immediately before TChmProject.SanitizeURL (near line 720 of chmfilewriter.pas) and must be extended to be like this:

Code: Pascal  [Select]
  1. const
  2.    protocols   : array[0..4] of string  = ('HTTP:', 'HTTPS:', 'FTP:', 'MS-ITS:', 'MAILTO:');
  3.    protocollen : array[0..4] of integer = ( 5, 6, 4, 7, 7);
  4.  

Marco, if you see this, could you please apply the modification? Of course I can write a bugreport...
Lazarus trunk / fpc 3.0.0 / Win32

wp

  • Hero Member
  • *****
  • Posts: 3600
Re: Non blocking bugs in chmcmd
« Reply #2 on: July 19, 2017, 12:39:44 am »
It took me some time to catch the other bug: All the "undefined anchor" errors occur for anchors which are identified by an ID, not by a name. But the local function ScanTags of TChmProject.ScanList (in chmfilewriter.pas) only checks for the attribute "name" of the "A" tag. This can be fixed as follows:

Code: Pascal  [Select]
  1. procedure TChmProject.ScanList(toscan,newfiles:TStrings;recursion:boolean);
  2. ...
  3. function scantags(prnt:TDomNode; const localname: string; filelist:TStringlist):TDomNode;
  4. var chld: TDomNode;
  5.     s   : ansistring;
  6.     i   : Integer;
  7.     att : String;     // <-- add
  8. ...
  9.              if s='A'then     // <-- Replace the "if s='A'" part by the following code:
  10.                begin
  11.                   //printattributes(chld,'');
  12.                   checkattributes(chld,'HREF',localname,filelist);
  13.                   att := 'NAME';
  14.                   s := findattribute(chld, att);
  15.                   if s = '' then begin
  16.                     att := 'ID';
  17.                     s := findattribute(chld, att);
  18.                   end;
  19.                   if s <> '' then
  20.                     begin
  21.                       i := fAnchorList.IndexOf(localname+'#'+s);
  22.                       if i < 0 then begin
  23.                         fAnchorList.Add(localname+'#'+s);
  24.                         Error(ChmNote,'New Anchor with '+att+' '+s+' found while scanning '+localname,1);
  25.                       end else if fAnchorList.Objects[i] = nil then
  26.                         Error(chmwarning,'Duplicate anchor definitions with '+att+' '+s+' found while scanning '+localname,1)
  27.                       else begin
  28.                         fAnchorList.Objects[i].Free;
  29.                         fAnchorList.Objects[i] := nil;
  30.                         Error(ChmNote,'Anchor with '+att+' '+s+' defined while scanning '+localname,1);
  31.                       end;
  32.                     end;
  33.                 end;
  34. ...

Running chmcmd for the provided chm project after this modification is fine without any errors or warnings.

Lazarus trunk / fpc 3.0.0 / Win32

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5526
Re: Non blocking bugs in chmcmd
« Reply #3 on: July 19, 2017, 09:50:00 am »
r36747 please check.

wp

  • Hero Member
  • *****
  • Posts: 3600
Re: Non blocking bugs in chmcmd
« Reply #4 on: July 19, 2017, 10:44:21 am »
Working fine. Thank you. Will it be backported, too?
Lazarus trunk / fpc 3.0.0 / Win32

Thaddy

  • Hero Member
  • *****
  • Posts: 3960
Re: Non blocking bugs in chmcmd
« Reply #5 on: July 19, 2017, 01:19:59 pm »
Frozen?
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

wp

  • Hero Member
  • *****
  • Posts: 3600
Re: Non blocking bugs in chmcmd
« Reply #6 on: July 19, 2017, 01:35:15 pm »
What do you mean?
Lazarus trunk / fpc 3.0.0 / Win32

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus