From: Subramanya Sastry
Date: Thu, 1 Nov 2012 16:21:10 +0000 (-0500)
Subject: Added Parsoid WT escaping tests (several disabled for PHP parser).
X-Git-Tag: 1.31.0-rc.0~21770^2
X-Git-Url: http://git.cyclocoop.org//%27%40script%40/%27?a=commitdiff_plain;h=16fabec27784e163ab07294b3291cec31f3339a2;p=lhc%2Fweb%2Fwiklou.git
Added Parsoid WT escaping tests (several disabled for PHP parser).
* Parsoid has to convert HTML to Wikitext in order to support the
Visual Editor. As part of this, it has to insert nowiki escapes
in several places wherever the text might be interpreted as
valid wikitext markup. The new tests test Parsoid's wikitext
escaping capabilities when the result HTML is serialized back to
Wikitext.
Change-Id: I392a5cbc2eeca921fcd4c44cbc37615b583240a5
---
diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt
index 27843a31de..5a204d079a 100644
--- a/tests/parser/parserTests.txt
+++ b/tests/parser/parserTests.txt
@@ -11517,6 +11517,740 @@ disabled
!!end
+#### The following section of tests are primarily to test
+#### wikitext escaping capabilities of Parsoid.
+#### A lot of the tests are disabled for the PHP parser either
+#### because of minor newline diffs or other reasons.
+#### As Parsoid serializer can handle newlines and other HTML
+#### more robustly, some of these tests might get reenabled
+#### for the PHP parser.
+
+#### --------------- Headings ---------------
+#### 0. Unnested
+#### 1. Nested inside html =foo=
+#### 2. Outside heading nest on a single line foo
*bar
+#### 3. Nested inside html with wikitext split by html tags
+#### 4. No escape needed
+#### 5. Empty headings
+#### 6. Heading chars in SOL context
+#### ----------------------------------------
+!! test
+Headings: 0. Unnested
+!! input
+=foo=
+
+=foo''a''=
+!! result
+=foo=
+
=fooa=
+
+!!end
+
+!! test
+Headings: 1. Nested inside html
+!! options
+disabled
+!! input
+==foo==
+===foo===
+====foo====
+=====foo=====
+======foo======
+=======foo=======
+!! result
+=foo=
+=foo=
+=foo=
+=foo=
+=foo=
+=foo=
+!!end
+
+!! test
+Headings: 2. Outside heading nest on a single line foo
*bar
+!! options
+disabled
+!! input
+=foo=
+*bar
+=foo=
+=bar
+=foo=
+=bar=
+!! result
+foo
*bar
+foo
=bar
+foo
=bar=
+!!end
+
+!! test
+Headings: 3. Nested inside html with wikitext split by html tags
+!! options
+disabled
+!! input
+=='''bold'''foo==
+!! result
+=boldfoo=
+!!end
+
+!! test
+Headings: 4. No escaping needed (testing just h1 and h2)
+!! options
+disabled
+!! input
+==foo=
+=foo==
+===foo==
+==foo===
+=''=''foo==
+===
+!! result
+=foo
+foo=
+=foo
+foo=
+=foo=
+=
+!!end
+
+!! test
+Headings: 5. Empty headings
+!! options
+disabled
+!! input
+==
+====
+======
+========
+==========
+============
+!! result
+
+
+
+
+
+
+!!end
+
+!! test
+Headings: 6. Heading chars in SOL context
+!! options
+disabled
+!! input
+=h1=
+!! result
+=h1=
+
+!!end
+
+#### --------------- Lists ---------------
+#### 0. Outside nests (*foo, etc.)
+#### 1. Nested inside html
+#### 2. Inside definition lists
+#### 3. Only bullets at start should be escaped
+#### 4. No escapes needed
+#### 5. No unnecessary escapes
+#### 6. Escape bullets in SOL position
+#### 7. Escape bullets in a multi-line context
+#### ----------------------------------------
+
+!! test
+Lists: 0. Outside nests
+!! input
+*foo
+
+#foo
+!! result
+*foo
+
#foo
+
+!!end
+
+!! test
+Lists: 1. Nested inside html
+!! input
+**foo
+
+*#foo
+
+*:foo
+
+*;foo
+
+#*foo
+
+##foo
+
+#:foo
+
+#;foo
+!! result
+
+
+
+
+- *foo
+
+- #foo
+
+- :foo
+
+- ;foo
+
+
+!!end
+
+!! test
+Lists: 2. Inside definition lists
+!! input
+;;foo
+
+;:foo
+
+;:foo
+:bar
+
+::foo
+!! result
+- ;foo
+
+- :foo
+
+- :foo
+
- bar
+
+- :foo
+
+
+!!end
+
+!! test
+Lists: 3. Only bullets at start of text should be escaped
+!! input
+**foo*bar
+
+**foo''it''*bar
+!! result
+
+
+
+!!end
+
+!! test
+Lists: 4. No escapes needed
+!! options
+disabled
+!! input
+*foo*bar
+
+*''foo''*bar
+
+*[[Foo]]: bar
+!! result
+
+
+
+!!end
+
+!! test
+Lists: 5. No unnecessary escapes
+!! input
+* bar [[foo]]
+
+*=bar [[foo]]
+
+*[[bar [[foo]]
+
+*]]bar [[foo]]
+
+*=bar foo]]=
+!! result
+
+
+
+
+
+
+!!end
+
+!! test
+Lists: 6. Escape bullets in SOL position
+!! options
+disabled
+!! input
+*foo
+!! result
+*foo
+
+!!end
+
+!! test
+Lists: 7. Escape bullets in a multi-line context
+!! input
+a
+*b
+!! result
+a
+*b
+
+!!end
+
+#### --------------- HRs ---------------
+#### 1. Single line
+#### -----------------------------------
+
+!! test
+HRs: 1. Single line
+!! options
+disabled
+!! input
+----
+----
+----
+=foo=
+----
+*foo
+!! result
+
----
+
=foo=
+
*foo
+!! end
+
+#### --------------- Tables ---------------
+#### 1a. Simple example
+#### 1b. No escaping needed (!foo)
+#### 1c. No escaping needed (|foo)
+#### 1d. No escaping needed (|}foo)
+####
+#### 2a. Nested in td (foo|bar | )
+#### 2b. Nested in td (foo||bar | )
+#### 2c. Nested in td -- no escaping needed(foo!!bar | )
+####
+#### 3a. Nested in th (foo!bar | )
+#### 3b. Nested in th (foo!!bar | )
+#### 3c. Nested in th -- no escaping needed(foo||bar | )
+####
+#### 4a. Escape -
+#### 4b. Escape +
+#### 4c. No escaping needed
+#### --------------------------------------
+
+!! test
+Tables: 1a. Simple example
+!! input
+{|
+|}
+!! result
+{|
+|}
+
+!! end
+
+!! test
+Tables: 1b. No escaping needed
+!! input
+!foo
+!! result
+!foo
+
+!! end
+
+!! test
+Tables: 1c. No escaping needed
+!! input
+|foo
+!! result
+|foo
+
+!! end
+
+!! test
+Tables: 1d. No escaping needed
+!! input
+|}foo
+!! result
+|}foo
+
+!! end
+
+!! test
+Tables: 2a. Nested in td
+!! options
+disabled
+!! input
+{|
+|foo|bar
+|}
+!! result
+
+
+!! end
+
+!! test
+Tables: 2b. Nested in td
+!! options
+disabled
+!! input
+{|
+|foo||bar
+|''it''foo||bar
+|}
+!! result
+
+
+!! end
+
+!! test
+Tables: 2c. Nested in td -- no escaping needed
+!! options
+disabled
+!! input
+{|
+|foo!!bar
+|}
+!! result
+
+
+!! end
+
+!! test
+Tables: 3a. Nested in th
+!! options
+disabled
+!! input
+{|
+!foo!bar
+|}
+!! result
+
+
+!! end
+
+!! test
+Tables: 3b. Nested in th
+!! options
+disabled
+!! input
+{|
+!foo!!bar
+|}
+!! result
+
+
+!! end
+
+!! test
+Tables: 3c. Nested in th -- no escaping needed
+!! options
+disabled
+!! input
+{|
+!foo||bar
+|}
+!! result
+
+
+!! end
+
+!! test
+Tables: 4a. Escape -
+!! options
+disabled
+!! input
+{|
+|-
+!-bar
+|-
+|-bar
+|}
+!! result
+
+!! end
+
+!! test
+Tables: 4b. Escape +
+!! options
+disabled
+!! input
+{|
+|-
+!+bar
+|-
+|+bar
+|}
+!! result
+
+!! end
+
+!! test
+Tables: 4c. No escaping needed
+!! options
+disabled
+!! input
+{|
+|-
+|foo-bar
+|foo+bar
+|-
+|''foo''-bar
+|''foo''+bar
+|}
+!! result
+
+foo-bar | foo+bar |
+foo-bar | foo+bar |
+
+!! end
+
+#### --------------- Links ---------------
+#### 1. Quote marks in link text
+#### 2. Wikilinks: Escapes needed
+#### 3. Wikilinks: No escapes needed
+#### 4. Extlinks: Escapes needed
+#### 5. Extlinks: No escapes needed
+#### --------------------------------------
+!! test
+Links 1. Quote marks in link text
+!! options
+disabled
+!! input
+[[Foo|Foo''boo'']]
+!! result
+Foo''boo''
+!! end
+
+!! test
+Links 2. WikiLinks: Escapes needed
+!! options
+disabled
+!! input
+[[Foo|[Foobar]]]
+[[Foo|Foobar]]]
+[[Foo|x [Foobar] x]]
+[[Foo|x [http://google.com g] x]]
+[[Foo|[[Bar]]]]
+[[Foo|x [[Bar]] x]]
+[[Foo||Bar]]
+!! result
+[Foobar]
+Foobar]
+x [Foobar] x
+x [http://google.com g] x
+[[Bar]]
+x [[Bar]] x
+|Bar
+!! end
+
+!! test
+Links 3. WikiLinks: No escapes needed
+!! options
+disabled
+!! input
+[[Foo|[Foobar]]
+[[Foo|foo|bar]]
+!! result
+[Foobar
+foo|bar
+!! end
+
+!! test
+Links 4. ExtLinks: Escapes needed
+!! options
+disabled
+!! input
+[http://google.com [google]]
+[http://google.com google]]
+!! result
+[google]
+google]
+!! end
+
+!! test
+Links 5. ExtLinks: No escapes needed
+!! options
+disabled
+!! input
+[http://google.com [google]
+!! result
+[google
+!! end
+
+#### --------------- Quotes ---------------
+#### 1. Quotes inside and
+#### 2. Link fragments separated by and tags
+#### 3. Link fragments inside and
+#### --------------------------------------
+!! test
+1. Quotes inside and
+!! input
+'''foo'''
+''''foo''''
+'''''foo'''''
+''''foo''''
+'''''foo'''''
+''''''foo''''''
+'''foo'''bar'''baz'''
+!! result
+'foo'
+''foo''
+'''foo'''
+'foo'
+''foo''
+'''foo'''
+foo'bar'baz
+
+!! end
+
+!! test
+2. Link fragments separated by and tags
+!! input
+[[''foo''hello]]
+
+[['''foo'''hello]]
+!! result
+[[foohello]]
+
[[foohello]]
+
+!! end
+
+!! test
+2. Link fragments inside and
+(FIXME: Escaping one or both of [[ and ]] is also acceptable --
+ this is one of the shortcomings of this format)
+!! input
+''[[foo'']]
+
+'''[[foo''']]
+!! result
+[[foo]]
+
[[foo]]
+
+!! end
+
+#### --------------- Paragraphs ---------------
+#### 1. No unnecessary escapes
+#### --------------------------------------
+
+!! test
+1. No unnecessary escapes
+!! input
+bar [[foo]]
+
+=bar [[foo]]
+
+[[bar [[foo]]
+
+]]bar [[foo]]
+
+=bar foo]]=
+!! result
+bar [[foo]]
+
=bar [[foo]]
+
[[bar [[foo]]
+
]]bar [[foo]]
+
=bar foo]]=
+
+!!end
+
+#### --------------- PRE ------------------
+#### 1. Leading space in SOL context should be escaped
+#### --------------------------------------
+!! test
+1. Leading space in SOL context should be escaped
+!! options
+disabled
+!! input
+ foo
+ foo
+!! result
+ foo
+ foo
+
+!! end
+
+#### --------------- HTML tags ---------------
+#### 1. a tags
+#### 2. other tags
+#### 3. multi-line html tag
+#### --------------------------------------
+!! test
+1. a tags
+!! options
+disabled
+!! input
+google
+!! result
+<a href="http://google.com">google</a>
+!! end
+
+!! test
+2. other tags
+!! input
+foo
+foo
+!! result
+<div>foo</div>
+<div style="color:red">foo</div>
+
+!! end
+
+!! test
+3. multi-line html tag
+!! input
+foo
+!! result
+<div
+>foo</div
+>
+
+!! end
+
+#### --------------- Others ---------------
+!! test
+Escaping nowikis
+!! input
+<nowiki>foo</nowiki>
+!! result
+<nowiki>foo</nowiki>
+
+!! end
+
TODO:
more images
more tables