Custom Tag stop while running

Author Message

Damien MARTIN

Friday 03 December 2010 7:17:26 am

Hi There I created a custom tag to allow users to add extra HTML/Javascript code in XMLBlock.

So I did the following modifications :

content.ini.append.php

[CustomTagSettings]
AvailableCustomTags[]=code
IsInline[code]=false

[code]
CustomAttributes[]=code

ezoe_attributes.ini.append.php

[code]
CustomAttributes[]=code

[CustomAttribute_code_code]
Name=Code
Type=text
Required=true

code.tpl

{wrap_php_func('html_entity_decode', array( $code ))}

With this, <b>UN</b> <i>test</i> <u><i>normal</i></u> run correctly but

<script type="text/javascript"> alert ( "Hello World" ) ;</script>

Stops while running with the following error :

<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; white-space: normal; font-size: 13px; " mce_fixed="1"><!-- START: including template: design/standard/templates/content/datatype/view/ezxmltags/code.tpl (design:content/datatype/view/ezxmltags/code.tpl) --> 
Mon code : <script typ  
<!-- STOP: including template: design/standard/templates/content/datatype/view/ezxmltags/code.tpl (design:content/datatype/view/ezxmltags/code.tpl) --></span>

I don't understand what happens.

Could someone explain me why it crash while running this very simple text ?

Thanks,

Damien

Ivo Lukac

Monday 06 December 2010 3:05:44 am

Hi,

With your code you are adding <script> tag in ezxml field which does not supported that tag.

I would suggest that you add additional eztext attribute in the class and deal with the javascript code in the template of the class.

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

Jérôme Vieilledent

Monday 06 December 2010 3:19:18 am

Another solution could be to activate raw HTML support via the literal tag.

You can do this in an override of content.ini. Here's what original content.ini says :

[literal]
AvailableClasses[]
# The class 'html' is disabled by default because it gives editors the
# possibility to insert html and javascript code in XML blocks.
# Don't enable the 'html' class unless you really trust all users who has
# privileges to edit objects containing XML blocks.
#AvailableClasses[]=html

This can be a solution, but since there is currently no security policy check on attributes, there might be a XSS security issue here...

Damien MARTIN

Monday 06 December 2010 3:22:33 am

Thanks Ivo,

But my users need to add more than JS. The should be able to add things like imagemap ou swf objects directly in the xmlblock.

I know that I can do this using object and embeded templates but it is very embarassing to have to create items before to insert them. So I would like to try "custom tag" instead.

So I suppose I will have no choice and create a new class named "custom_code" or something like that a create a kind of "piece of code library".

Thank you very much again.

Ivo Lukac

Monday 06 December 2010 4:02:28 am

"

Another solution could be to activate raw HTML support via the literal tag.

You can do this in an override of content.ini. Here's what original content.ini says :

[literal]
AvailableClasses[]
# The class 'html' is disabled by default because it gives editors the
# possibility to insert html and javascript code in XML blocks.
# Don't enable the 'html' class unless you really trust all users who has
# privileges to edit objects containing XML blocks.
#AvailableClasses[]=html

This can be a solution, but since there is currently no security policy check on attributes, there might be a XSS security issue here...

"

If I were him I would rather not do that :)

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

André R.

Monday 06 December 2010 4:23:22 am

literal.html is the only soulution that will accept raw html.
If you want to use custom tag, then you will need to create one pr use case, one for image maps (with attributes for input), one for script (with url as attribute) and so on.

You can setup custom tag to behave as inline-block in oe with the following settings in content.ini:

## Displays the custom tag as an image so you cannot create sub content.
## Will use custom image if there is a custom attribute on the tag named 'image_url'
#IsInline[externalimage]=image
## Lets you specify 22x22 icon to use on custom image tag if it doesn't have 'image_url'
#InlineImageIconPath[mashup]=images/tango/image-x-generic22.png

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Jérôme Vieilledent

Monday 06 December 2010 5:22:39 am

"

If I were him I would rather not do that

"

Why not ? If this fits to the need, then this is the solution ! ;)

The only thing is that the website administrator has to trust his contributors, that's all ! Besides, this is the case for every CMS that propose such a feature...

Damien MARTIN

Monday 06 December 2010 6:25:28 am

Thank you very much everybody.

I called my customer and we decided together to create objects before adding them in XML Block.

I hope that this thread will be usefull for other persons.

Thanks,

Damien

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 15 2025 08:09:44
Script start
Timing: Jan 15 2025 08:09:44
Module start 'layout'
Timing: Jan 15 2025 08:09:44
Module start 'content'
Timing: Jan 15 2025 08:09:46
Module end 'content'
Timing: Jan 15 2025 08:09:46
Script end

Main resources:

Total runtime1.7722 sec
Peak memory usage6,144.0000 KB
Database Queries76

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 684.5391183.6875
Module start 'layout' 0.00630.0032 868.226652.5703
Module start 'content' 0.00951.7610 920.79691,991.1563
Module end 'content' 1.77050.0017 2,911.9531144.5469
Script end 1.7722  3,056.5000 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00600.3377160.0004
Check MTime0.00120.0703160.0001
Mysql Total
Database connection0.00100.054310.0010
Mysqli_queries1.666094.0068760.0219
Looping result0.00090.0506740.0000
Template Total1.734697.920.8673
Template load0.00420.235720.0021
Template processing1.730497.637720.8652
Template load and register function0.00140.078610.0014
states
state_id_array0.00070.038010.0007
state_identifier_array0.00350.200020.0018
Override
Cache load0.00390.2191680.0001
Sytem overhead
Fetch class attribute can translate value0.00150.083440.0004
Fetch class attribute name0.00250.1417120.0002
XML
Image XML parsing0.00700.393240.0017
class_abstraction
Instantiating content class attribute0.00000.0017160.0000
General
dbfile0.00700.3950370.0002
String conversion0.00000.000540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
8content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
17content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/emphasize.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/emphasize.tplEdit templateOverride template
7content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 48
 Number of unique templates used: 9

Time used to render debug report: 0.0001 secs