jsalvata    2004/01/24 17:39:24

  Modified:    src/htmlparser/org/htmlparser/scanners ImageScanner.java
  Log:
  Undo change to remove dependency on JOrphanUtils.
  
  Revision  Changes    Path
  1.4       +24 -24    
jakarta-jmeter/src/htmlparser/org/htmlparser/scanners/ImageScanner.java
  
  Index: ImageScanner.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/htmlparser/org/htmlparser/scanners/ImageScanner.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ImageScanner.java 7 Jan 2004 00:38:22 -0000       1.3
  +++ ImageScanner.java 25 Jan 2004 01:39:24 -0000      1.4
  @@ -73,7 +73,6 @@
   //////////////////
   import java.util.Hashtable;
   
  -import org.apache.jorphan.util.JOrphanUtils;
   import org.htmlparser.tags.ImageTag;
   import org.htmlparser.tags.Tag;
   import org.htmlparser.tags.data.TagData;
  @@ -120,34 +119,35 @@
           {
               table = tag.getAttributes();
               relativeLink = (String) table.get("SRC");
  +
               if (relativeLink != null)
               {
                   relativeLink = ParserUtils.removeChars(relativeLink, '\n');
                   relativeLink = ParserUtils.removeChars(relativeLink, '\r');
               }
  -                     if (relativeLink==null || relativeLink.length()==0) {
  -                             // try fix
  -                             String tagText = tag.getText();
  -                             int indexSrc = tagText.indexOf("src");
  -                             if (indexSrc != -1) {
  -                                     // There is a bug with AttributeParser when the
  -                                     // alt tag value is zero length. To get around
  -                                     // the bug, I strip out alt="" and then append
  -                                     // it at the end. When the alt attribute has a
  -                                     // value, the bug does not appear.
  -                                     //JDK1.4: String newtext = 
tagText.replaceAll("alt=\"\" ","");
  -                                     String newtext = 
JOrphanUtils.replaceFirst(tagText,"alt=\"\" ","");
  -                                     tag.setText(newtext + " alt=\"\"");
  -                                     table = tag.redoParseAttributes();
  -                                     relativeLink = (String)table.get("SRC");
  -                             } 
  -                     }
  -                     if (relativeLink == null){
  -                             return ""; 
  -                     }else{
  -                             tag.setAttributes(table);
  -                             return relativeLink;
  -                     }
  +            if (relativeLink == null || relativeLink.length() == 0)
  +            {
  +                // try fix
  +                String tagText = tag.getText().toUpperCase();
  +                int indexSrc = tagText.indexOf("SRC");
  +                if (indexSrc != -1)
  +                {
  +                    // There is a missing equals.
  +                    tag.setText(
  +                        tag.getText().substring(0, indexSrc + 3)
  +                            + "="
  +                            + tag.getText().substring(
  +                                indexSrc + 3,
  +                                tag.getText().length()));
  +                    table = tag.redoParseAttributes();
  +                    relativeLink = (String) table.get("SRC");
  +
  +                }
  +            }
  +            if (relativeLink == null)
  +                return "";
  +            else
  +                return processor.extract(relativeLink, url);
           }
           catch (Exception e)
           {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to