Details
-
Bug
-
Status: Closed
-
High
-
Resolution: Outdated
-
r2.12.17
-
None
-
None
-
FF 3.6.6
Description
When a <script> tag is added to a Xinha field of a document (using the 'Toggle HTML source' button), extra HTML is added when the document is saved. The added HTML often ruins the layout of the page that renders the document.
Steps to reproduce:
1a. add the 'Toggle HTML source' button to the Xinha editor (add the value 'htmlmode' to the property Xinha.config.toolbar)
1b. Change html cleaner to allow script tag (in console at '/hippo:configuration/hippo:frontend/cms/cms-services/htmlCleanerService/cleaner.config/hippohtmlcleaner:cleanup/' a 'hippohtmlcleaner:cleanupElement' with 'hippohtmlcleaner:name' set to 'script' and 'hippohtmlcleaner:attributes' set to 'src')
1c. create a document type with a field of type hippostd:html
2. in the CMS, create a document of this type
3. click the Xinha field to edit it
4. click the 'Toggle HTML source' button
5. add, for example, the following text (the script will include a video in a page):
<p><script type="text/javascript" src="http://bb.bbvms.com/p/QuickTour2_526/c/1089249.js"></script></p>
6. click the 'Toggle HTML source' button again
7. save the document
8. click the Xinha field to edit it again
9. click the 'Toggle HTML source' button
Expected behavior: the field's contents is identical
Actual behavior: the field's contents is changed to:
<p>
<script src="http://bb.bbvms.com/p/QuickTour2_526/c/1089249.js" type="text/javascript">
</p>
</body>
</html></body>
</html></p>
The added tags at the end will ruin the layout of most pages.
After some trial and error I found a workaround that at least keeps the page layout intact: make the included script a singular tag.
For the example above, you would need to change the Xinha field contents to:
<p><script src="http://bb.bbvms.com/p/QuickTour2_526/c/1089249.js" type="text/javascript"/></p>
When the document is then saved, the field's content is changed to:
<p>
<script src="http://bb.bbvms.com/p/QuickTour2_526/c/1089249.js" type="text/javascript">
</p><span id="XinhaEditingPostion"></span></script>
</p>
While this is still ugly, it will not affect the page layout anymore. Each time the document is saved again, the field's content will change some more (all ampersands between the <script> tags will be reinterpreted to &), but that also does not affect the final page layout.