Relates :
|
FULL PRODUCT VERSION : A DESCRIPTION OF THE PROBLEM : This bug is result of 6245596 "fix" . <img src="http://www/test?a=b&c=d&e=f"> src will be changed to <img src="http://www/test?a=b&c;=d&e;=f"> because of String str = '&' + nm + ';'; and image will not be displayed. My solution would be to add local variable suffix : String suffix = ""; switch (ch) { case '\n': ln++; ch = readCh(); lfCount++; break; case '\r': ln++; if ((ch = readCh()) == '\n') { ch = readCh(); crlfCount++; } else { crCount++; } break; case ';': suffix = ";"; ch = readCh(); break; } and later String str = '&' + nm + suffix; STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Run source code below and you will see wrong result. (with additional semicolons) EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - <img src="http://www/test?a=b&c=d&e=f"> ACTUAL - <img src="http://www/test?a=b&c;=d&e;=f"> REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.io.IOException; import java.io.StringReader; import java.util.Enumeration; import javax.swing.text.MutableAttributeSet; import javax.swing.text.html.HTML; import javax.swing.text.html.HTMLEditorKit.ParserCallback; import javax.swing.text.html.parser.ParserDelegator; /** * */ /** * @author Milos * */ public class HtmlParserTest extends ParserCallback { String text = "<img src=\"http://www/test?a=b&c=d&e=f\">"; public void parse() throws IOException { StringReader reader = new StringReader(text); ParserDelegator delegator = new ParserDelegator(); delegator.parse(reader, this, true); // the third parameter is TRUE to ignore charset directive } @Override public void handleSimpleTag(HTML.Tag t, MutableAttributeSet a, int pos) { StringBuilder sb = new StringBuilder(); sb.append("<" + t); for (Enumeration<?> en = a.getAttributeNames(); en.hasMoreElements(); ) { Object name = en.nextElement(); String nameStr = name.toString(); if (!nameStr.equals("_implied_") && !nameStr.equals("style")) { sb.append(" ").append(nameStr).append("=\"").append(a.getAttribute(name)).append("\""); } } sb.append(">"); System.out.println(sb); } public static void main(String[] args) throws IOException { HtmlParserTest parser = new HtmlParserTest(); parser.parse(); } } ---------- END SOURCE ----------