You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by wo...@apache.org on 2003/11/29 22:36:30 UTC
cvs commit: jakarta-jmeter/src/htmlparser/org/htmlparser/scanners ImageScanner.java
woolfel 2003/11/29 13:36:29
Modified: src/htmlparser/org/htmlparser/scanners ImageScanner.java
Log:
fixed a bug with ImageScanner, which caused it to miss images when the alt
attribute is zero length.
PR:
Obtained from:
Submitted by:
Reviewed by:
CVS: ----------------------------------------------------------------------
CVS: PR:
CVS: If this change addresses a PR in the problem report tracking
CVS: database, then enter the PR number(s) here.
CVS: Obtained from:
CVS: If this change has been taken from another system, such as NCSA,
CVS: then name the system in this line, otherwise delete it.
CVS: Submitted by:
CVS: If this code has been contributed to Apache by someone else; i.e.,
CVS: they sent us a patch or a new module, then include their name/email
CVS: address here. If this is your work then delete this line.
CVS: Reviewed by:
CVS: If we are doing pre-commit code reviews and someone else has
CVS: reviewed your changes, include their name(s) here.
CVS: If you have not had it reviewed then delete this line.
Revision Changes Path
1.2 +22 -23 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ImageScanner.java 16 Oct 2003 19:12:48 -0000 1.1
+++ ImageScanner.java 29 Nov 2003 21:36:29 -0000 1.2
@@ -124,29 +124,28 @@
relativeLink = ParserUtils.removeChars(relativeLink, '\n');
relativeLink = ParserUtils.removeChars(relativeLink, '\r');
}
- 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);
+ 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.
+ String newtext = tagText.replaceAll("alt=\"\" ","");
+ tag.setText(newtext + " alt=\"\"");
+ table = tag.redoParseAttributes();
+ relativeLink = (String)table.get("SRC");
+ }
+ }
+ if (relativeLink == null){
+ return "";
+ }else{
+ tag.setAttributes(table);
+ return relativeLink;
+ }
}
catch (Exception e)
{
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org