Disregard; serialization was clearly inappropriate here.

On Tue, Jul 14, 2009 at 12:52 PM, <[email protected]> wrote:

> Reviewers: shindig.remailer_gmail.com,
>
> Description:
> An issue was discovered recently where message bundles with CDATA
> content sections had their content dropped eg.
> <msg name="foo"><![CDATA[ bar ]]></msg>
>
> Root cause is that HTML serialization ignores serializing CDATA
> sections. It's not clear to me why, so I'm proposing this trivial fix.
>
> Please review this at http://codereview.appspot.com/91114
>
> Affected files:
>
>  
> java/gadgets/src/main/java/org/apache/shindig/gadgets/parse/DefaultHtmlSerializer.java
>
>  
> java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/MessageBundleTest.java
>
>
> Index:
> java/gadgets/src/main/java/org/apache/shindig/gadgets/parse/DefaultHtmlSerializer.java
> ===================================================================
> ---
> java/gadgets/src/main/java/org/apache/shindig/gadgets/parse/DefaultHtmlSerializer.java
>  (revision 794025)
> +++
> java/gadgets/src/main/java/org/apache/shindig/gadgets/parse/DefaultHtmlSerializer.java
>  (working copy)
> @@ -58,9 +58,6 @@
>       throws IOException {
>     if (n == null) return;
>     switch (n.getNodeType()) {
> -      case Node.CDATA_SECTION_NODE: {
> -        break;
> -      }
>       case Node.COMMENT_NODE: {
>         writeComment(n, output);
>         break;
> @@ -93,6 +90,7 @@
>         output.append("&").append(n.getNodeName()).append(";");
>         break;
>       }
> +      case Node.CDATA_SECTION_NODE:
>       case Node.TEXT_NODE: {
>         writeText(n, output);
>         break;
> Index:
> java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/MessageBundleTest.java
> ===================================================================
> ---
> java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/MessageBundleTest.java
>       (revision 794025)
> +++
> java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/MessageBundleTest.java
>       (working copy)
> @@ -84,6 +84,16 @@
>     assertEquals(ImmutableMap.of("key", "value"), bundle.getMessages());
>   }
>
> +  @Test
> +  public void containsCdataSection() throws Exception {
> +    String cdataXml =
> +       "<messagebundle>" +
> +       "  <msg name='key'><![CDATA[<span id='foo'>data</span>]]></msg>" +
> +       "</messagebundle>";
> +    MessageBundle bundle = new MessageBundle(locale, cdataXml);
> +    assertEquals(ImmutableMap.of("key", "<span id='foo'>data</span>"),
> bundle.getMessages());
> +  }
> +
>   @Test(expected = SpecParserException.class)
>   public void missingNameThrows() throws SpecParserException {
>     String xml = "<messagebundle><msg>foo</msg></messagebundle>";
>
>
>

Reply via email to