On Jun 27, 2009, at 10:16 AM, Sergiu Dumitriu wrote:
Vincent Massol wrote:
On Jun 26, 2009, at 8:37 PM, Sergiu Dumitriu wrote:
vmassol (SVN) wrote:
Author: vmassol Date: 2009-06-19 21:18:47 +0200 (Fri, 19 Jun 2009) New Revision: 21360
Modified: platform/core/branches/xwiki-core-1.8/xwiki-xml/src/main/java/org/ xwiki/xml/XMLUtils.java platform/core/branches/xwiki-core-1.8/xwiki-xml/src/test/java/org/ xwiki/xml/internal/html/DefaultHTMLCleanerTest.java Log: XWIKI-4005: HMTL Cleaner should not expand empty elements for BR and HR in order to support IE6
Modified: platform/core/branches/xwiki-core-1.8/xwiki-xml/src/main/ java/org/xwiki/xml/XMLUtils.java =================================================================== --- platform/core/branches/xwiki-core-1.8/xwiki-xml/src/main/java/ org/xwiki/xml/XMLUtils.java 2009-06-19 16:35:08 UTC (rev 21359) +++ platform/core/branches/xwiki-core-1.8/xwiki-xml/src/main/java/ org/xwiki/xml/XMLUtils.java 2009-06-19 19:18:47 UTC (rev 21360) @@ -213,7 +225,16 @@ format.setOmitDeclaration(omitDeclaration);
XMLOutputter outputter = new XWikiXMLOutputter(format, omitDoctype); - return outputter.outputString(jdomDoc); + String result = outputter.outputString(jdomDoc); + + // Since we need to support IE6 we must generate compact form for the following HTML elements (otherwise they + // won't be understood by IE6): + for (String specialElement : OMIT_ELEMENT_CLOSE_SET) { + result = result.replaceAll(MessageFormat.format("<{0}></{0}>", specialElement), Shouldn't this be something like "<{0}[^>]*+></{0}>"? I doubt that there really is <img></img>, and if it is, it won't make much difference which way it's written.
This is not a regex but a simple MessageFormat.format(). BTW A Regex would probably be better since the Pattern could be precompiled (at the expense of more complex code though).
No, it is a regexp. The result of the MessageFormat is used for replaceAll, which treats the first argument as a regexp.
ah right :) Now I don't understand your regex does. I understand it would replace for ex "<imghello whatever></img>". Why would we want this? It's very likely I don't understand the regex you pasted since it doesnt make sense to me. Thanks -Vincent
+ MessageFormat.format("<{0}/>", specialElement)); + } + + return result;
-- Sergiu Dumitriu http://purl.org/net/sergiu/ _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs