View Issue Details

IDProjectCategoryView StatusLast Update
0003489JEDI VCL00 JVCL Componentspublic2006-06-08 07:37
ReportertuxscreenAssigned Toobones 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionno change required 
Product Version3.10 
Target VersionFixed in Version 
Summary0003489: JvHTMLParser parses no attributes under somehow normal circumstances
DescriptionThe latest change introduces new behaviour so that no attributes are parsed (inside a valid condition)
e.g. I have a condition setup with AddCondition('URL', '<a', '</a>');
to get all URLs in a html-file.

Because my start-tag is of Length 2 the condition is never met:
      if (Length(StartTag1) > 2) and (StartTag1[Length(StartTag1)] = '>') then
      begin
        // split the tag so tags with attributes can be found
        Delete(StartTag1, Length(StartTag1), 1);
        StartTag2 := '>';
      end;

So, StartTag2 is not set (in my case).

Next the code checks if StartTag2 is not empty and if this is true,
the Attributes are parsed:
      // Str2 now contains eveything between the start and end tags
      Str2 := Copy(Str, PTagInfo(Items[Index]).BeginContext,
        PTagInfo(Items[Index]).EndContext - PTagInfo(Items[Index]).BeginContext);
      if StartTag2 = '' then
        Str3 := ''
      else
        //Str3 contains the start tag as found, may include attributes or other tags
        Str3 := Copy(Str, PTagInfo(Items[Index]).BeginPos,
          PTagInfo(Items[Index]).BeginContext - PTagInfo(Items[Index]).BeginPos - 1);
      if Assigned(FOnKeyFound) then
        FOnKeyFound(Self, FKeys[PTagInfo(Items[Index]).Key], Str2, Str);
      if Assigned(FOnKeyFoundEx) then
      begin
        ParseAttributes(AttributesList, Str3);
        FOnKeyFoundEx(Self, FKeys[PTagInfo(Items[Index]).Key], Str2, Str,
          PTagInfo(Items[Index])^, AttributesList);
      end;


As you can see Str3 is used in the condition above, but Str3 is only set if StartTag2 is not empty and StartTag2 is only set for Tags greater 2.

Additional Informationquick hack patch:
>> Starting line 376 (JvHTMLParser.pas)
  with FTagList do
  begin
    for Index := 0 to Count - 1 do
    begin
      // Str2 now contains eveything between the start and end tags
      Str2 := Copy(Str, PTagInfo(Items[Index]).BeginContext,
        PTagInfo(Items[Index]).EndContext - PTagInfo(Items[Index]).BeginContext);
      if StartTag2 = '' then
        Str3 := ''
      else
        //Str3 contains the start tag as found, may include attributes or other tags
        Str3 := Copy(Str, PTagInfo(Items[Index]).BeginPos,
          PTagInfo(Items[Index]).BeginContext - PTagInfo(Items[Index]).BeginPos - 1);
      if Assigned(FOnKeyFound) then
        FOnKeyFound(Self, FKeys[PTagInfo(Items[Index]).Key], Str2, Str);
      if Assigned(FOnKeyFoundEx) then
      begin
        if Str3<>'' then
           ParseAttributes(AttributesList, Str3)
        else
           ParseAttributes(AttributesList, Str2);
        FOnKeyFoundEx(Self, FKeys[PTagInfo(Items[Index]).Key], Str2, Str,
          PTagInfo(Items[Index])^, AttributesList);
      end;
    end;
  end;
  finally
>> End line 400 (in original file)
TagsNo tags attached.

Activities

CarlEfird

2006-02-05 16:10

reporter   ~0008505

It expects a complete tag, not a partial tag, to determine that it is supposed to look for attributes - i.e. AddCondition('URL', '<a>', '</a>');

obones

2006-02-09 07:54

administrator   ~0008529

As indicated by CarlEfird, you should indicate the full tag, not a partial tag. Please let us know how that goes.

tuxscreen

2006-03-11 07:23

reporter   ~0008659

Last edited: 2006-03-11 07:28

OK, in this point you are right.

But it is even more worse than that...

If you use multiple conditions and the last condition does not require
attribute-parsing, then the _local_ variable Starttag2 contains nothing and is
unusable.

I suppose, that the Starttag2 variable shall be included into the
FKeys.Objects[I] struct.

Any advice from your side?

BR
tux


Added example:

If you use the following it _doesn't work_:
    AddCondition('URLTEXT', '<a>', '</a>');
    AddCondition('URL', 'href=http://', '/a>');

If you flip the two conditions it works:
    AddCondition('URL', 'href=http://', '/a>');
    AddCondition('URLTEXT', '<a>', '</a>');

obones

2006-04-07 06:53

administrator   ~0009021

Please provide the zipped sources of a sample application, I don't quite get what you are trying to do. To me it even starts looking as if you are trying to use that component for something that it was not designed for.

obones

2006-06-08 07:37

administrator   ~0009480

Well, no answers, no sample program, I'm considering that this issue is fixed in the latest version:

http://jvcl.sf.net/daily/

Issue History

Date Modified Username Field Change
2006-02-02 05:28 tuxscreen New Issue
2006-02-05 16:10 CarlEfird Note Added: 0008505
2006-02-09 07:54 obones Note Added: 0008529
2006-02-09 07:54 obones Status new => feedback
2006-03-11 07:23 tuxscreen Note Added: 0008659
2006-03-11 07:24 tuxscreen Note Edited: 0008659
2006-03-11 07:28 tuxscreen Note Edited: 0008659
2006-04-07 06:53 obones Note Added: 0009021
2006-06-08 07:37 obones Status feedback => resolved
2006-06-08 07:37 obones Resolution open => no change required
2006-06-08 07:37 obones Assigned To => obones
2006-06-08 07:37 obones Note Added: 0009480