01: /**
02: * LibreSource
03: * Copyright (C) 2004-2008 Artenum SARL / INRIA
04: * http://www.libresource.org - contact@artenum.com
05: *
06: * This file is part of the LibreSource software,
07: * which can be used and distributed under license conditions.
08: * The license conditions are provided in the LICENSE.TXT file
09: * at the root path of the packaging that enclose this file.
10: * More information can be found at
11: * - http://dev.libresource.org/home/license
12: *
13: * Initial authors :
14: *
15: * Guillaume Bort / INRIA
16: * Francois Charoy / Universite Nancy 2
17: * Julien Forest / Artenum
18: * Claude Godart / Universite Henry Poincare
19: * Florent Jouille / INRIA
20: * Sebastien Jourdain / INRIA / Artenum
21: * Yves Lerumeur / Artenum
22: * Pascal Molli / Universite Henry Poincare
23: * Gerald Oster / INRIA
24: * Mariarosa Penzi / Artenum
25: * Gerard Sookahet / Artenum
26: * Raphael Tani / INRIA
27: *
28: * Contributors :
29: *
30: * Stephane Bagnier / Artenum
31: * Amadou Dia / Artenum-IUP Blois
32: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33: */package org.libresource.web.wiki.macros;
34:
35: import org.radeox.api.engine.context.InitialRenderContext;
36:
37: import org.radeox.macro.Preserved;
38: import org.radeox.macro.parameter.MacroParameter;
39:
40: import java.io.IOException;
41: import java.io.Writer;
42:
43: public class HtmlMacro extends Preserved {
44: public HtmlMacro() throws Exception {
45: super ();
46: addSpecial('[');
47: addSpecial(']');
48: addSpecial('{');
49: addSpecial('}');
50: addSpecial('*');
51: addSpecial('-');
52: addSpecial('\\');
53:
54: // FIXME add special caractere with accents
55: }
56:
57: public String getName() {
58: return "html";
59: }
60:
61: public void execute(Writer writer, MacroParameter params)
62: throws IllegalArgumentException, IOException {
63: try {
64: // allow scripts ???
65: //<strike class="strike"><script> alert(document.cookie) </script> </strike>
66: String html = params.getContent().replaceAll("<", "<");
67: html = html.replaceAll(">", ">");
68: writer.write("<div class=\"html-content\">" + replace(html)
69: + "</div>");
70: } catch (IOException e) {
71: throw e;
72: } catch (IllegalArgumentException e) {
73: throw e;
74: } catch (Exception e) {
75: throw new IllegalArgumentException("error in html macro : "
76: + e.getMessage());
77: }
78: }
79:
80: public String getDescription() {
81: return "By pass wiki engine to allow HTML code in content";
82: }
83:
84: public String[] getParamDescription() {
85: return new String[] { "the html block" };
86: }
87:
88: public void setInitialContext(InitialRenderContext arg0) {
89: }
90:
91: public int compareTo(Object arg0) {
92: return 0;
93: }
94: }
|