You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@shindig.apache.org by "lipeng (JIRA)" <ji...@apache.org> on 2009/06/29 08:48:47 UTC

[jira] Created: (SHINDIG-1103) The bug is that DOMDocument->loadHtml will remove tages like in script.

The bug is that DOMDocument->loadHtml will remove tages like </b> in script.
----------------------------------------------------------------------------

                 Key: SHINDIG-1103
                 URL: https://issues.apache.org/jira/browse/SHINDIG-1103
             Project: Shindig
          Issue Type: Bug
          Components: PHP
    Affects Versions: trunk
            Reporter: lipeng
             Fix For: trunk


Fixed shindig/php/test/index.php, We can request "http://shindig/test/index.php?test=GadgetRewriterTest" to get GadgetRewriterTest's result.
Added shindig/php/test/gadgets/GadgetRewriterTest.php, To test when activate rewriter by rewrite_by_default=true, the rewrite code should change content within the content tag in application xml.
<code>
<Content type="html" view="default"> 
    <script>var test='<b>BIG WORDS</b>'</script>
    <h1>Hello, world!</h1>
</Content>
</code>
be changed to
<code>
    <script>var test='<b>BIG WORDS'</script>
    <h1>Hello, world!</h1>
</code>
The bug is that DOMDocument->loadHtml will remove tages like </b> in script. Every loadHtml calling has that problem. Do you have any solution for this?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHINDIG-1103) The bug is that DOMDocument->loadHtml will remove tages like in script.

Posted by "Chris Chabot (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHINDIG-1103?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12728018#action_12728018 ] 

Chris Chabot commented on SHINDIG-1103:
---------------------------------------

I've applied the patch, and the index change looks good, however the GadgetRewriterTest has some issues, when i run it as-is i get this error:

1) testRewrite(GadgetRewriterTest)
GadgetException: Invalid view specified for this gadget
/Library/WebServer/Documents/shindig/php/test/gadgets/GadgetRewriterTest.php:81
/Library/WebServer/Documents/shindig/php/test/index.php:53
/Library/WebServer/Documents/shindig/php/test/index.php:85

When I change the 'default' view to 'profile', I run into another error:

1) testRewrite(GadgetRewriterTest)
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ -1,2 +1,6 @@
+
+  
     <script>var test='<b>BIG WORDS</b>'</script>
-    <h1>Hello, world!</h1>
\ No newline at end of file
+    <h1>Hello, world!</h1>
+  
+  
\ No newline at end of file

/Library/WebServer/Documents/shindig/php/test/gadgets/GadgetRewriterTest.php:105
/Library/WebServer/Documents/shindig/php/test/index.php:53
/Library/WebServer/Documents/shindig/php/test/index.php:85


So I've committed the GadgetRewriterTest without the actual test part (so we don't get failing tests everywhere), Could you please submit a new patch for that bit?



> The bug is that DOMDocument->loadHtml will remove tages like </b> in script.
> ----------------------------------------------------------------------------
>
>                 Key: SHINDIG-1103
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-1103
>             Project: Shindig
>          Issue Type: Bug
>          Components: PHP
>    Affects Versions: trunk
>            Reporter: lipeng
>             Fix For: trunk
>
>         Attachments: index-rewriter-test.patch
>
>
> Fixed shindig/php/test/index.php, We can request "http://shindig/test/index.php?test=GadgetRewriterTest" to get GadgetRewriterTest's result.
> Added shindig/php/test/gadgets/GadgetRewriterTest.php, To test when activate rewriter by rewrite_by_default=true, the rewrite code should change content within the content tag in application xml.
> <code>
> <Content type="html" view="default"> 
>     <script>var test='<b>BIG WORDS</b>'</script>
>     <h1>Hello, world!</h1>
> </Content>
> </code>
> be changed to
> <code>
>     <script>var test='<b>BIG WORDS'</script>
>     <h1>Hello, world!</h1>
> </code>
> The bug is that DOMDocument->loadHtml will remove tages like </b> in script. Every loadHtml calling has that problem. Do you have any solution for this?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (SHINDIG-1103) The bug is that DOMDocument->loadHtml will remove tages like in script.

Posted by "lipeng (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SHINDIG-1103?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

lipeng updated SHINDIG-1103:
----------------------------

    Attachment: index-rewriter-test.patch

Fixed shindig/php/test/index.php, We can request "http://shindig/test/index.php?test=GadgetRewriterTest" to get GadgetRewriterTest's result.
Added shindig/php/test/gadgets/GadgetRewriterTest.php, To test when activate rewriter by rewrite_by_default=true, the rewrite code should change content within the content tag in application xml.
<code>
<Content type="html" view="default"> 
    <script>var test='<b>BIG WORDS</b>'</script>
    <h1>Hello, world!</h1>
</Content>
</code>
be changed to
<code>
    <script>var test='<b>BIG WORDS'</script>
    <h1>Hello, world!</h1>
</code>

The bug is that DOMDocument->loadHtml will remove tages like </b> in script. Every loadHtml calling has that problem. Do you have any solution for this?

> The bug is that DOMDocument->loadHtml will remove tages like </b> in script.
> ----------------------------------------------------------------------------
>
>                 Key: SHINDIG-1103
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-1103
>             Project: Shindig
>          Issue Type: Bug
>          Components: PHP
>    Affects Versions: trunk
>            Reporter: lipeng
>             Fix For: trunk
>
>         Attachments: index-rewriter-test.patch
>
>
> Fixed shindig/php/test/index.php, We can request "http://shindig/test/index.php?test=GadgetRewriterTest" to get GadgetRewriterTest's result.
> Added shindig/php/test/gadgets/GadgetRewriterTest.php, To test when activate rewriter by rewrite_by_default=true, the rewrite code should change content within the content tag in application xml.
> <code>
> <Content type="html" view="default"> 
>     <script>var test='<b>BIG WORDS</b>'</script>
>     <h1>Hello, world!</h1>
> </Content>
> </code>
> be changed to
> <code>
>     <script>var test='<b>BIG WORDS'</script>
>     <h1>Hello, world!</h1>
> </code>
> The bug is that DOMDocument->loadHtml will remove tages like </b> in script. Every loadHtml calling has that problem. Do you have any solution for this?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHINDIG-1103) The bug is that DOMDocument->loadHtml will remove tages like in script.

Posted by "Kevin Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHINDIG-1103?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12725061#action_12725061 ] 

Kevin Brown commented on SHINDIG-1103:
--------------------------------------

Technically your content isn't valid xml (or even valid html). In XML the structure is:

<script>
  - (text)=var test='
  -<b>
  ----BIG WORDS

Try one of the following:

1. Escape the HTML entities in your string.
2. Escape the text of the script as an HTML comment

> The bug is that DOMDocument->loadHtml will remove tages like </b> in script.
> ----------------------------------------------------------------------------
>
>                 Key: SHINDIG-1103
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-1103
>             Project: Shindig
>          Issue Type: Bug
>          Components: PHP
>    Affects Versions: trunk
>            Reporter: lipeng
>             Fix For: trunk
>
>         Attachments: index-rewriter-test.patch
>
>
> Fixed shindig/php/test/index.php, We can request "http://shindig/test/index.php?test=GadgetRewriterTest" to get GadgetRewriterTest's result.
> Added shindig/php/test/gadgets/GadgetRewriterTest.php, To test when activate rewriter by rewrite_by_default=true, the rewrite code should change content within the content tag in application xml.
> <code>
> <Content type="html" view="default"> 
>     <script>var test='<b>BIG WORDS</b>'</script>
>     <h1>Hello, world!</h1>
> </Content>
> </code>
> be changed to
> <code>
>     <script>var test='<b>BIG WORDS'</script>
>     <h1>Hello, world!</h1>
> </code>
> The bug is that DOMDocument->loadHtml will remove tages like </b> in script. Every loadHtml calling has that problem. Do you have any solution for this?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHINDIG-1103) The bug is that DOMDocument->loadHtml will remove tages like in script.

Posted by "lipeng (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHINDIG-1103?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12725077#action_12725077 ] 

lipeng commented on SHINDIG-1103:
---------------------------------

sorry, that is my wrong.
so I can change the code to this, now see it:
<code>
<Content type="html" view="default"> 
    <![CDATA[
    <script>var test='<b>BIG WORDS</b>'</script> 
    <h1>Hello, world!</h1> 
    ]]>
</Content>  
</code>
this is a valid xml structure.
but the bug is still here.

I escape '</b>' to '<\/b>'
the bug be gone.

but this is the correct method?
do we need addslashes for the '/' character in application xml code?

> The bug is that DOMDocument->loadHtml will remove tages like </b> in script.
> ----------------------------------------------------------------------------
>
>                 Key: SHINDIG-1103
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-1103
>             Project: Shindig
>          Issue Type: Bug
>          Components: PHP
>    Affects Versions: trunk
>            Reporter: lipeng
>             Fix For: trunk
>
>         Attachments: index-rewriter-test.patch
>
>
> Fixed shindig/php/test/index.php, We can request "http://shindig/test/index.php?test=GadgetRewriterTest" to get GadgetRewriterTest's result.
> Added shindig/php/test/gadgets/GadgetRewriterTest.php, To test when activate rewriter by rewrite_by_default=true, the rewrite code should change content within the content tag in application xml.
> <code>
> <Content type="html" view="default"> 
>     <script>var test='<b>BIG WORDS</b>'</script>
>     <h1>Hello, world!</h1>
> </Content>
> </code>
> be changed to
> <code>
>     <script>var test='<b>BIG WORDS'</script>
>     <h1>Hello, world!</h1>
> </code>
> The bug is that DOMDocument->loadHtml will remove tages like </b> in script. Every loadHtml calling has that problem. Do you have any solution for this?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHINDIG-1103) The bug is that DOMDocument->loadHtml will remove tages like in script.

Posted by "lipeng (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHINDIG-1103?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12725956#action_12725956 ] 

lipeng commented on SHINDIG-1103:
---------------------------------

Hey,Chris

yes, libxml2 is bad:)
can you patch the test patch? 
Fixed shindig/php/test/index.php, We can request "http://shindig/test/index.php?test=GadgetRewriterTest"  to get GadgetRewriterTest's result. 

I think it is useful:)

> The bug is that DOMDocument->loadHtml will remove tages like </b> in script.
> ----------------------------------------------------------------------------
>
>                 Key: SHINDIG-1103
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-1103
>             Project: Shindig
>          Issue Type: Bug
>          Components: PHP
>    Affects Versions: trunk
>            Reporter: lipeng
>             Fix For: trunk
>
>         Attachments: index-rewriter-test.patch
>
>
> Fixed shindig/php/test/index.php, We can request "http://shindig/test/index.php?test=GadgetRewriterTest" to get GadgetRewriterTest's result.
> Added shindig/php/test/gadgets/GadgetRewriterTest.php, To test when activate rewriter by rewrite_by_default=true, the rewrite code should change content within the content tag in application xml.
> <code>
> <Content type="html" view="default"> 
>     <script>var test='<b>BIG WORDS</b>'</script>
>     <h1>Hello, world!</h1>
> </Content>
> </code>
> be changed to
> <code>
>     <script>var test='<b>BIG WORDS'</script>
>     <h1>Hello, world!</h1>
> </code>
> The bug is that DOMDocument->loadHtml will remove tages like </b> in script. Every loadHtml calling has that problem. Do you have any solution for this?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHINDIG-1103) The bug is that DOMDocument->loadHtml will remove tages like in script.

Posted by "Chris Chabot (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHINDIG-1103?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12725107#action_12725107 ] 

Chris Chabot commented on SHINDIG-1103:
---------------------------------------

Hey Lipeng,

libxml2's html loading is notoriously picky and easy to anger when it comes to <script></script> blocks; It's also used for os-template and os-data script block parsing, and the only way that I got it not to break on that was by regex'ing out those os-template/data script blocks and parse them separately .. otherwise  it would do exactly what you're seeing here, remove all the trailing tags.

Kevin's solution is the only one that works for now.. and the only viable alternative would be to implement a HTML parser from scratch, the available open source ones are either huge (and lots of code == very very slow PHP execution, so not acceptable) or just downright buggy.. which might be fine if you're making a email generator, but won't do at all for Shindig. 

> The bug is that DOMDocument->loadHtml will remove tages like </b> in script.
> ----------------------------------------------------------------------------
>
>                 Key: SHINDIG-1103
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-1103
>             Project: Shindig
>          Issue Type: Bug
>          Components: PHP
>    Affects Versions: trunk
>            Reporter: lipeng
>             Fix For: trunk
>
>         Attachments: index-rewriter-test.patch
>
>
> Fixed shindig/php/test/index.php, We can request "http://shindig/test/index.php?test=GadgetRewriterTest" to get GadgetRewriterTest's result.
> Added shindig/php/test/gadgets/GadgetRewriterTest.php, To test when activate rewriter by rewrite_by_default=true, the rewrite code should change content within the content tag in application xml.
> <code>
> <Content type="html" view="default"> 
>     <script>var test='<b>BIG WORDS</b>'</script>
>     <h1>Hello, world!</h1>
> </Content>
> </code>
> be changed to
> <code>
>     <script>var test='<b>BIG WORDS'</script>
>     <h1>Hello, world!</h1>
> </code>
> The bug is that DOMDocument->loadHtml will remove tages like </b> in script. Every loadHtml calling has that problem. Do you have any solution for this?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (SHINDIG-1103) The bug is that DOMDocument->loadHtml will remove tages like in script.

Posted by "lipeng (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SHINDIG-1103?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

lipeng updated SHINDIG-1103:
----------------------------

    Attachment: GadgetRewriterTest.patch

hi,Chris

I am so sorry.
now, this patch work well.


> The bug is that DOMDocument->loadHtml will remove tages like </b> in script.
> ----------------------------------------------------------------------------
>
>                 Key: SHINDIG-1103
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-1103
>             Project: Shindig
>          Issue Type: Bug
>          Components: PHP
>    Affects Versions: trunk
>            Reporter: lipeng
>             Fix For: trunk
>
>         Attachments: GadgetRewriterTest.patch, index-rewriter-test.patch
>
>
> Fixed shindig/php/test/index.php, We can request "http://shindig/test/index.php?test=GadgetRewriterTest" to get GadgetRewriterTest's result.
> Added shindig/php/test/gadgets/GadgetRewriterTest.php, To test when activate rewriter by rewrite_by_default=true, the rewrite code should change content within the content tag in application xml.
> <code>
> <Content type="html" view="default"> 
>     <script>var test='<b>BIG WORDS</b>'</script>
>     <h1>Hello, world!</h1>
> </Content>
> </code>
> be changed to
> <code>
>     <script>var test='<b>BIG WORDS'</script>
>     <h1>Hello, world!</h1>
> </code>
> The bug is that DOMDocument->loadHtml will remove tages like </b> in script. Every loadHtml calling has that problem. Do you have any solution for this?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (SHINDIG-1103) The bug is that DOMDocument->loadHtml will remove tages like in script.

Posted by "Chris Chabot (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SHINDIG-1103?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chris Chabot resolved SHINDIG-1103.
-----------------------------------

    Resolution: Fixed
      Assignee: Chris Chabot

Thanks for the fix, test executes perfectly for me now.

> The bug is that DOMDocument->loadHtml will remove tages like </b> in script.
> ----------------------------------------------------------------------------
>
>                 Key: SHINDIG-1103
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-1103
>             Project: Shindig
>          Issue Type: Bug
>          Components: PHP
>    Affects Versions: trunk
>            Reporter: lipeng
>            Assignee: Chris Chabot
>             Fix For: trunk
>
>         Attachments: GadgetRewriterTest.patch, index-rewriter-test.patch
>
>
> Fixed shindig/php/test/index.php, We can request "http://shindig/test/index.php?test=GadgetRewriterTest" to get GadgetRewriterTest's result.
> Added shindig/php/test/gadgets/GadgetRewriterTest.php, To test when activate rewriter by rewrite_by_default=true, the rewrite code should change content within the content tag in application xml.
> <code>
> <Content type="html" view="default"> 
>     <script>var test='<b>BIG WORDS</b>'</script>
>     <h1>Hello, world!</h1>
> </Content>
> </code>
> be changed to
> <code>
>     <script>var test='<b>BIG WORDS'</script>
>     <h1>Hello, world!</h1>
> </code>
> The bug is that DOMDocument->loadHtml will remove tages like </b> in script. Every loadHtml calling has that problem. Do you have any solution for this?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.