Commit 0bae09bd authored by Simon Urli's avatar Simon Urli
Browse files

XRENDERING-600: Faulty repeated insertion of 'class="wikiattachmentlink"' by WYSIWYG editing

  * Handle wikiattachmentlink the same way we handle wikiinternallink
    class
  * Add integration tests to cover the bug
parent a9fac25f
.#-----------------------------------------------------
.input|xhtml/1.0
.#-----------------------------------------------------
<p><!--startwikilink:true|-|attach|-|file.pdf--><span class="wikiattachmentlink"><a href="/xwiki/bin/download/Path/To/file.pdf">t<em>itl</em>e</a></span><!--stopwikilink--></p>
.#-----------------------------------------------------
.expect|xwiki/2.1
.#-----------------------------------------------------
[[t//itl//e>>attach:file.pdf]]
.#-----------------------------------------------------
.expect|event/1.0
.#-----------------------------------------------------
beginDocument
beginParagraph
beginLink [Typed = [true] Type = [attach] Reference = [file.pdf]] [false]
onWord [t]
beginFormat [ITALIC]
onWord [itl]
endFormat [ITALIC]
onWord [e]
endLink [Typed = [true] Type = [attach] Reference = [file.pdf]] [false]
endParagraph
endDocument
\ No newline at end of file
.#-----------------------------------------------------
.input|xhtml/1.0
.#-----------------------------------------------------
<p><!--startwikilink:true|-|attach|-|file.pdf--><span class="wikiattachmentlink"><a href="/xwiki/bin/download/Path/To/file.pdf">title</a></span><!--stopwikilink--></p>
.#-----------------------------------------------------
.expect|xwiki/2.1
.#-----------------------------------------------------
[[title>>attach:file.pdf]]
.#-----------------------------------------------------
.expect|event/1.0
.#-----------------------------------------------------
beginDocument
beginParagraph
beginLink [Typed = [true] Type = [attach] Reference = [file.pdf]] [false]
onWord [title]
endLink [Typed = [true] Type = [attach] Reference = [file.pdf]] [false]
endParagraph
endDocument
\ No newline at end of file
...@@ -62,15 +62,17 @@ protected void begin(TagContext context) ...@@ -62,15 +62,17 @@ protected void begin(TagContext context)
// Ex: <a href="..."><span class="wikicreatelinktext">...</span><span class="wikicreatelinkqm">?</span></a> // Ex: <a href="..."><span class="wikicreatelinktext">...</span><span class="wikicreatelinkqm">?</span></a>
WikiParameter classParam = params.getParameter("class"); WikiParameter classParam = params.getParameter("class");
if (classParam != null) { if (classParam != null) {
if (classParam.getValue().contains("wikigeneratedlinkcontent")) String classParamValue = classParam.getValue();
if (classParamValue.contains("wikigeneratedlinkcontent"))
{ {
setAccumulateContent(true); setAccumulateContent(true);
} else if ("wikilink".equals(classParam.getValue()) } else if ("wikilink".equals(classParamValue)
|| "wikicreatelink".equals(classParam.getValue()) || "wikicreatelink".equals(classParamValue)
|| "wikiexternallink".equals(classParam.getValue())) || "wikiexternallink".equals(classParamValue)
|| "wikiattachmentlink".equals(classParamValue))
{ {
// Nothing to do // Nothing to do
} else if ("xwikirenderingerror".equals(classParam.getValue())) { } else if ("xwikirenderingerror".equals(classParamValue)) {
setAccumulateContent(true); setAccumulateContent(true);
} else { } else {
super.begin(context); super.begin(context);
...@@ -89,15 +91,17 @@ protected void end(TagContext context) ...@@ -89,15 +91,17 @@ protected void end(TagContext context)
if (!nonGeneratedContent) { if (!nonGeneratedContent) {
WikiParameter classParam = context.getParams().getParameter("class"); WikiParameter classParam = context.getParams().getParameter("class");
if (classParam != null) { if (classParam != null) {
if (classParam.getValue().contains("wikigeneratedlinkcontent")) String classParamValue = classParam.getValue();
if (classParamValue.contains("wikigeneratedlinkcontent"))
{ {
setAccumulateContent(false); setAccumulateContent(false);
} else if ("wikilink".equals(classParam.getValue()) } else if ("wikilink".equals(classParamValue)
|| "wikicreatelink".equals(classParam.getValue()) || "wikicreatelink".equals(classParamValue)
|| "wikiexternallink".equals(classParam.getValue())) || "wikiexternallink".equals(classParamValue)
|| "wikiattachmentlink".equals(classParamValue))
{ {
// Nothing to do // Nothing to do
} else if ("xwikirenderingerror".equals(classParam.getValue())) { } else if ("xwikirenderingerror".equals(classParamValue)) {
setAccumulateContent(false); setAccumulateContent(false);
} else { } else {
super.end(context); super.end(context);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment