Fix https://github.com/jamesagnew/hapi-fhir/issues/1488 - We should not
use HTML encoding on entities when serializing narratives
This commit is contained in:
parent
0b196e5188
commit
ecfdf43034
|
@ -362,7 +362,7 @@ public class XhtmlNode implements IBaseXhtml {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String retVal = new XhtmlComposer(XhtmlComposer.HTML).compose(this);
|
String retVal = new XhtmlComposer(XhtmlComposer.XML).compose(this);
|
||||||
retVal = XhtmlDt.preprocessXhtmlNamespaceDeclaration(retVal);
|
retVal = XhtmlDt.preprocessXhtmlNamespaceDeclaration(retVal);
|
||||||
return retVal;
|
return retVal;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package org.hl7.fhir.utilities.xhtml;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
public class XhtmlNodeTest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See https://github.com/jamesagnew/hapi-fhir/issues/1488
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testDontEncodeHtmlOnlyEntities() {
|
||||||
|
|
||||||
|
// Entity that appears in XHTML not not in XML
|
||||||
|
XhtmlNode node = new XhtmlNode();
|
||||||
|
node.setValueAsString("<div>®</div>");
|
||||||
|
assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">®</div>", node.getValueAsString());
|
||||||
|
|
||||||
|
// Entity that appears in both
|
||||||
|
node = new XhtmlNode();
|
||||||
|
node.setValueAsString("<div><</div>");
|
||||||
|
assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\"><</div>", node.getValueAsString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue