Skip to content

Commit

Permalink
SAK-41271 Fixes some broken wiki macros (sakaiproject#6515)
Browse files Browse the repository at this point in the history
smarquard authored Feb 6, 2019
1 parent a3ea7f5 commit d0e030b
Showing 11 changed files with 31 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ SpanMacro.0=1,class: The class to assign to this block.
SpanMacro.1=id: An id to assign to this block.
SpanMacro.2=anchor: An anchor to assign to this block
SpanMacro.3=Places a span around a section of rwiki rendered content.
MathMacro.0=This is a basic macro that places span/div tags with an appropriate class around the math text. \nThe contents of this macro are pre-escaped, however you cannot put {math} in the contents of this macro, place {{}math} instead.
MathMacro.0=This is a basic macro that places span/div tags with an appropriate class around the math text. The contents of this macro are pre-escaped, however you cannot put \{ math \} in the contents of this macro, place {{}math} instead.
MathMacro.1=1: put "display" here for the maths to be placed in a div
SpecializedRenderContext.7=Link Cant be resolved
SpecializedRenderContext.20=Link Cant be resolved
Original file line number Diff line number Diff line change
@@ -85,9 +85,10 @@ public void execute(Writer writer, MacroParameter params)
if (params.getLength() == 1)
{
url = text;
text = Encoder.escape(text);
}

text = Encoder.escape(text);

if (url != null && text != null)
{
if (target == null)
@@ -126,7 +127,7 @@ public void execute(Writer writer, MacroParameter params)
writer.write("<a href=\"" + url + "\""); //$NON-NLS-1$ //$NON-NLS-2$
if (!"none".equals(target)) //$NON-NLS-1$
{
writer.write(" target=\"" + target + "\""); //$NON-NLS-1$ //$NON-NLS-2$
writer.write(" target=\"" + Encoder.escape(target) + "\""); //$NON-NLS-1$ //$NON-NLS-2$
}
writer.write(">"); //$NON-NLS-1$
writer.write(text);
2 changes: 1 addition & 1 deletion rwiki/rwiki-util/radeox/src/bundle/conf/asinservices.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Amazon.de http://www.amazon.de/exec/obidos/ASIN/
amazon.com http://amzn.com/
2 changes: 1 addition & 1 deletion rwiki/rwiki-util/radeox/src/bundle/conf/bookservices.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Amazon.com http://www.amazon.com/exec/obidos/ASIN/
amazon.com http://amzn.com/
#Preistester http://www.preistester.de/cgi-bin/pt/buchs.pl?query=profi&isbn=
#Book-Butler http://book-butler.com/?evt=go&in=
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ LinkMacro.23=link needs a name and a url as argument
TableMacro.1=TableMacro: missing table content
ApiMacro.0=1: class name, e.g. java.lang.Object or java.lang.Object@Java131
ApiMacro.1=?2: mode, e.g. Java12, Ruby, defaults to Java
ApiMacro.8=api macro needs one or two paramaters
ApiMacro.8=api macro needs one or two parameters
ApiDoc.14=Binding|BaseUrl|Converter Name\n
CodeMacro.0=?1: syntax highlighter to use, defaults to java
IsbnMacro.0=1: isbn number
@@ -35,7 +35,7 @@ MacroListMacro.11={table}
MailToMacro.0=1: mail address
XrefMacro.0=1: class name, e.g. java.lang.Object or java.lang.Object@Nanning
XrefMacro.1=?2: line number
XrefMacro.7=xref macro needs one or two paramaters
RfcMacro.3=needs an RFC numer as argument
XrefMacro.7=xref macro needs one or two parameters
RfcMacro.3=needs an RFC number as argument
TextFileUrlMapper.7=Service|Url\n

Original file line number Diff line number Diff line change
@@ -60,7 +60,8 @@ public void execute(Writer writer, MacroParameter params)

if (params.getLength() == 1)
{
AsinServices.getInstance().appendUrl(writer, params.get("0")); //$NON-NLS-1$
String asin = params.get("0").replaceAll("[^0-9A-Za-z]", "");
AsinServices.getInstance().appendUrl(writer, asin); //$NON-NLS-1$
return;
}
else
Original file line number Diff line number Diff line change
@@ -61,7 +61,8 @@ public void execute(Writer writer, MacroParameter params)

if (params.getLength() == 1)
{
BookServices.getInstance().appendUrl(writer, params.get("0")); //$NON-NLS-1$
String isbn = params.get("0").replaceAll("[^0-9-]", "");
BookServices.getInstance().appendUrl(writer, isbn); //$NON-NLS-1$
return;
}
else
Original file line number Diff line number Diff line change
@@ -86,9 +86,8 @@ public void execute(Writer writer, MacroParameter params)
if (params.getLength() == 1)
{
url = text;
text = Encoder.toEntity(text.charAt(0))
+ Encoder.escape(text.substring(1));
}
text = Encoder.toEntity(text.charAt(0)) + Encoder.escape(text.substring(1));

if (url != null && text != null)
{
@@ -122,7 +121,7 @@ public void execute(Writer writer, MacroParameter params)
if (!"none".equals(target)) //$NON-NLS-1$
{
writer.write(" target=\""); //$NON-NLS-1$
writer.write(target);
writer.write(Encoder.escape(target));
writer.write("\" "); //$NON-NLS-1$
}
writer.write(">"); //$NON-NLS-1$
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@
import lombok.extern.slf4j.Slf4j;
import org.radeox.Messages;
import org.radeox.api.macro.MacroParameter;
import org.radeox.util.Encoder;

/*
* Displays a mail to link. @author stephan @team sonicteam
@@ -56,7 +57,7 @@ public void execute(Writer writer, MacroParameter params)

if (params.getLength() == 1)
{
String mail = params.get("0"); //$NON-NLS-1$
String mail = Encoder.escape(params.get("0")); //$NON-NLS-1$
writer.write("<a href=\"mailto:" + mail + "\">" + mail + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
return;
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@
import lombok.extern.slf4j.Slf4j;
import org.radeox.Messages;
import org.radeox.api.macro.MacroParameter;
import org.radeox.util.Encoder;

/*
* Macro to display quotations from other sources. The output is wrapped usually
@@ -65,13 +66,13 @@ public void execute(Writer writer, MacroParameter params)
String source = Messages.getString("QuoteMacro.4"); // i18n //$NON-NLS-1$
if (params.getLength() == 2)
{
source = params.get(1);
source = Encoder.escape(params.get(1));
}
// if more than one was present, we
// should show a description for the link
if (params.getLength() > 0)
{
writer.write("<a href=\"" + params.get(0) + "\">"); //$NON-NLS-1$ //$NON-NLS-2$
writer.write("<a href=\"" + Encoder.escape(params.get(0)) + "\">"); //$NON-NLS-1$ //$NON-NLS-2$
writer.write(source);
writer.write("</a>"); //$NON-NLS-1$
}
28 changes: 11 additions & 17 deletions rwiki/rwiki-util/radeox/src/java/org/radeox/macro/RfcMacro.java
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@

import org.radeox.Messages;
import org.radeox.api.macro.MacroParameter;
import org.radeox.util.Encoder;

/*
* Macro to easily link to RFCs. The website to link to is currently hard wired.
@@ -48,18 +49,21 @@ public void execute(Writer writer, MacroParameter params)
throws IllegalArgumentException, IOException
{

String number = params.get("0"); //$NON-NLS-1$
try {
Integer.parseInt(number);
} catch (NumberFormatException nfe) {
throw new IllegalArgumentException(Messages.getString("RfcMacro.3")); //$NON-NLS-1$
}

if (params.getLength() == 1)
{
String number = params.get("0"); //$NON-NLS-1$
String view = "RFC" + number; //$NON-NLS-1$
// ftp://ftp.rfc-editor.org/in-notes/rfc3300.txt
// http://zvon.org/tmRFC/RFC3300/Output/index.html
appendRfc(writer, number, view);
return;
}
else if (params.getLength() == 2)
{
String number = params.get(0);
String view = params.get(1);
appendRfc(writer, number, view);
}
@@ -72,20 +76,10 @@ else if (params.getLength() == 2)
public void appendRfc(Writer writer, String number, String view)
throws IOException, IllegalArgumentException
{
// writer.write("<a href=\"ftp://ftp.rfc-editor.org/in-notes/rfc");
try
{

Integer dummy = Integer.getInteger(number);
}
catch (Exception e)
{
throw new IllegalArgumentException();
}
writer.write("<a href=\"http://zvon.org/tmRFC/RFC"); //$NON-NLS-1$
writer.write("<a href=\"https://www.rfc-editor.org/info/rfc"); //$NON-NLS-1$
writer.write(number);
writer.write("/Output/index.html\">"); //$NON-NLS-1$
writer.write(view);
writer.write("\">"); //$NON-NLS-1$
writer.write(Encoder.escape(view));
writer.write("</a>"); //$NON-NLS-1$
return;
}

0 comments on commit d0e030b

Please sign in to comment.