Skip to content

Fixing nested list markup to avoid invalid ordering in firefox 68 and up #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions main/trunk/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<property name="javadoc" value="doc"/>
<property name="version" value="1.0"/>
<property name="status" value="-BETA-3"/>
<property name="encoding" value="iso-8859-1"/>
<taskdef resource="clovertasks"/>
<target name="with.clover">
<clover-setup initString="radeox_coverage.db/"/>
Expand Down Expand Up @@ -56,7 +57,7 @@
<mkdir dir="${javadoc}/api"/>
</target>
<target name="compile" depends="prepare">
<javac srcdir="${src}" destdir="${out}" classpathref="classpath" debug="${debug}"/>
<javac srcdir="${src}" destdir="${out}" classpathref="classpath" debug="${debug}" encoding="${encoding}"/>
</target>
<target name="jar-api" depends="compile" description="build the Radeox API jar">
<jar destfile="${dist}/radeox-api.jar" excludes="**/CVS" manifest="${src}/META-INF/manifest.radeox-api"
Expand All @@ -74,7 +75,7 @@
</jar>
</target>
<target name="compile-test" depends="prepare">
<javac srcdir="${srctest}" destdir="${outtest}" classpathref="classpath" debug="${debug}">
<javac srcdir="${srctest}" destdir="${outtest}" classpathref="classpath" debug="${debug}" encoding="${encoding}">
<classpath path="${dist}/radeox.jar"/>
</javac>
</target>
Expand Down
4 changes: 2 additions & 2 deletions main/trunk/conf/radeox_markup.properties
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ filter.wikilink.match=([A-Z][a-z]+([A-Z][a-z]+)+)

filter.param.match=\\{\\$([^}]*)\\}

filter.list.match=(^[\\p{Space}]*([-#*]+|[-#*]*[iIaA1ghHkKj]+\\.)[\\p{Space}]+([^\r\n]+)[\r\n]*)+
filter.list.match=(^[\\p{Space}]*([-#*]+|[-#*]*[iIaA1ghHkKj]+\\.)[ ]+([^\r\n]+)[\r\n]*)+
#filter.list.match=^[\\p{Space}]*([-#*]+[\\p{Space}]+|[-#*]?[iIaA1ghHkKj][-#*iIaA1ghHkKj]*\\.[\\p{Space}]+)(\r?\n[\\p{Space}]*(?:([-#*]+[\\p{Space}]+)|([-#*]?[iIaA1ghHkKj][-#*iIaA1ghHkKj]*\\.[\\p{Space}]+))|[^\\r\\n]+)*$
#filter.list.match=^[\\p{Space}]*([-#*]+[\\p{Space}]+|[iIaA1ghHkKj][iIaA1ghHkKj]*[.][\\p{Space}]+)(?:([-#*]+[\\p{Space}]+)|([iIaA1ghHkKj][iIaA1ghHkKj]*[.][\\p{Space}]+)|.+)*$
filter.list.Creole.match=(^[\\p{Space}]*([#-]+)[\\p{Space}]+([^\r\n]+)[\r\n]*)+
filter.list.Creole.match=(^[\\p{Space}]*([#-]+)[ ]+([^\r\n]+)[\r\n]*)+
25 changes: 22 additions & 3 deletions main/trunk/src/java/org/radeox/filter/ListFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public class ListFilter extends LocaleRegexTokenFilter implements CacheFilter {
private final static Map openList = new HashMap();
private final static Map closeList = new HashMap();

private static final String NEWLINE = "\n";
private static final String LI_OPEN = "<li>";
private static final String LI_CLOSE = "</li>";
private static final String UL_CLOSE = "</ul>";
private static final String OL_CLOSE = "</ol>";

Expand Down Expand Up @@ -136,22 +139,38 @@ private void addList(StringBuffer buffer, BufferedReader reader) throws IOExcept

for (int i = sharedPrefixEnd; i < lastBullet.length; i++) {
//Logger.log("closing " + lastBullet[i]);
buffer.append(LI_CLOSE + NEWLINE);
buffer.append(closeList.get(new Character(lastBullet[i]))).append("\n");
}

for (int i = sharedPrefixEnd; i < bullet.length; i++) {
//Logger.log("opening " + bullet[i]);
if(i > 0)
{
buffer.append(NEWLINE);
}
buffer.append(openList.get(new Character(bullet[i]))).append("\n");
buffer.append(LI_OPEN);
}

if(lastBullet.length >= bullet.length)
{
buffer.append(LI_CLOSE + NEWLINE);
buffer.append(LI_OPEN);
}
buffer.append("<li>");

buffer.append(line.substring(line.indexOf(' ') + 1));
buffer.append("</li>\n");
lastBullet = bullet;
}

for (int i = lastBullet.length - 1; i >= 0; i--) {
//Logger.log("closing " + lastBullet[i]);
buffer.append(LI_CLOSE + NEWLINE);
buffer.append(closeList.get(new Character(lastBullet[i])));
if(i > 0)
{
buffer.append(NEWLINE);
}
}
}
}
}
44 changes: 35 additions & 9 deletions main/trunk/src/test/org/radeox/filter/ListFilterTest.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.radeox.filter;

/*
* Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand All @@ -27,23 +27,29 @@ public class ListFilterTest extends FilterTestSupport {
private static final String RESULT_UNNUMBERED_2 = "<ul class=\"minus\">\n<li>test</li>\n<li>test</li>\n</ul>";
private static final String RESULT_ORDERED = "<ol>\n<li>test</li>\n<li>test</li>\n<li>test</li>\n</ol>";
private static final String RESULT_NESTED_SIMPLE = "<ul class=\"minus\">\n" +
"<li>test</li>\n" +
"<li>test\n" +
"<ul class=\"minus\">\n" +
"<li>test</li>\n" +
"<li>test</li>\n" +
"</ul>\n" +
"<li>test</li>\n" +
"</li>\n" +
"</ul>";
private static final String RESULT_NESTED_LIST = "<ul class=\"minus\">\n" +
"<li>test</li>\n" +
"<li>test\n" +
"<ol class=\"alpha\">\n" +
"<li>\n" +
"<ol class=\"alpha\">\n" +
"<li>test</li>\n" +
"<li>test</li>\n" +
"</ol>\n" +
"</li>\n" +
"</ol>\n" +
"</li>\n" +
"<li>test</li>\n" +
"</ul>";

protected void setUp() throws Exception {
@Override
protected void setUp() throws Exception {
filter = new ListFilter();
// context.getRenderContext().setRenderEngine((RenderEngine)
// new MockWikiRenderEngine()
Expand All @@ -59,6 +65,8 @@ public void testListsWithStrike() {
assertEquals("<ul class=\"minus\">\n" +
"<li>test</li>\n" +
"<li>test</li>\n" +
"</ul>-----\n" +
"<ul class=\"minus\">\n" +
"<li>test</li>\n" +
"</ul>", filter.filter("- test\n- test\n\n-----\n\n- test", context));
}
Expand Down Expand Up @@ -90,15 +98,15 @@ public void testOrderedListCreole() {
}

public void testSimpleNestedList() {
assertEquals(RESULT_NESTED_SIMPLE, filter.filter("- test\r\n-- test\r\n-- test\r\n- test", context));
assertEquals(RESULT_NESTED_SIMPLE, filter.filter("- test\r\n-- test\r\n-- test", context));
}

public void testSimpleNestedListCreole() {
assertEquals(RESULT_NESTED_SIMPLE, filter.filter("- test\r\n-- test\r\n-- test\r\n- test", context));
assertEquals(RESULT_NESTED_SIMPLE, filterCreole.filter("- test\r\n-- test\r\n-- test", context));
}

public void testNestedList() {
assertEquals(RESULT_NESTED_LIST, filter.filter("- test\n-a. test\n-a. test\n- test", context));
assertEquals(RESULT_NESTED_LIST, filter.filter("- test\n-aa. test\n-aa. test\n- test", context));
}

public void testSequentialLists() {
Expand All @@ -117,4 +125,22 @@ public void testListWithLinks() {
"<li>[test test2]</li>\n" +
"</ul>", filter.filter("- [test]\n- [test1]\n- [test test2]\n", context));
}

public void testWrongListFormat() {
final String markup = "paragraph01\r\n"+
"\r\n" +
// wrong list element mark (no content)
"--- \n" +
"\r\n" +
"paragraph02\r\n" +
"\r\n" +
// wrong list element mark (no space and no content)
"---\n" +
"\r\n" +
"paragraph03\r\n";
final String out = filter.filter(markup, context);
// output should be the same as input
assertEquals(markup, out);
}

}
144 changes: 144 additions & 0 deletions pom.xml.tobefixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>radeox</groupId>
<artifactId>radeox</artifactId>
<version>1.1-verbis</version>
<name>radeox</name>
<build>
<sourceDirectory>main/trunk/src/java</sourceDirectory>
<testSourceDirectory>main/trunk/src/test</testSourceDirectory>
<resources>
<resource>
<directory>main/trunk/src/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>main/trunk/conf</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<executions>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<debug>true</debug>
<source>1.7</source>
<target>1.7</target>
</configuration>
</execution>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<debug>true</debug>
<source>1.7</source>
<target>1.7</target>
</configuration>
</execution>
</executions>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>iso-8859-1</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.jmock</groupId>
<artifactId>jmock</artifactId>
<version>2.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jmock</groupId>
<artifactId>jmock-junit3</artifactId>
<version>2.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jmock</groupId>
<artifactId>jmock-cglib</artifactId>
<version>1.0.0.RC1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jmock</groupId>
<artifactId>jmock-legacy</artifactId>
<version>2.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>oro</groupId>
<artifactId>oro</artifactId>
<version>2.0.8</version>
</dependency>
<dependency>
<groupId>oro</groupId>
<artifactId>oro</artifactId>
<version>2.0.8</version>
</dependency>
<dependency>
<groupId>picocontainer</groupId>
<artifactId>picocontainer</artifactId>
<version>1.1</version>
<exclusions>
<exclusion>
<groupId>xstream</groupId>
<artifactId>xstream</artifactId>
</exclusion>
<exclusion>
<artifactId>xpp3</artifactId>
<groupId>xpp3</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.0-rc1-snapshot</version>
</dependency>
<dependency>
<groupId>junitperf</groupId>
<artifactId>junitperf</artifactId>
<version>1.8</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>