Kaynağa Gözat

Add tests for < and > in wilink titles/template names (#104)

tags/v0.4.1
Ben Kurtovic 9 yıl önce
ebeveyn
işleme
07d4577c33
3 değiştirilmiş dosya ile 112 ekleme ve 0 silme
  1. +70
    -0
      tests/tokenizer/integration.mwtest
  2. +14
    -0
      tests/tokenizer/templates.mwtest
  3. +28
    -0
      tests/tokenizer/wikilinks.mwtest

+ 70
- 0
tests/tokenizer/integration.mwtest Dosyayı Görüntüle

@@ -241,3 +241,73 @@ name: newline_and_comment_in_template_name_7
label: a template name containing a newline followed by a comment
input: "{{foobar\n<!|key=value}}"
output: [Text(text="{{foobar\n<!|key=value}}")]

---

name: tag_in_link_title
label: HTML tags are invalid in link titles, even when complete
input: "[[foo<i>bar</i>baz]]"
output: [Text(text="[[foo"), TagOpenOpen(), Text(text="i"), TagCloseOpen(padding=""), Text(text="bar"), TagOpenClose(), Text(text="i"), TagCloseClose(), Text(text="baz]]")]

---

name: tag_in_template_name
label: HTML tags are invalid in template names, even when complete
input: "{{foo<i>bar</i>baz}}"
output: [Text(text="{{foo"), TagOpenOpen(), Text(text="i"), TagCloseOpen(padding=""), Text(text="bar"), TagOpenClose(), Text(text="i"), TagCloseClose(), Text(text="baz}}")]

---

name: tag_in_link_text
label: HTML tags are valid in link text
input: "[[foo|<i>bar</i>baz]]"
output: [WikilinkOpen(), Text(text="foo"), WikilinkSeparator(), TagOpenOpen(), Text(text="i"), TagCloseOpen(padding=""), Text(text="bar"), TagOpenClose(), Text(text="i"), TagCloseClose(), Text(text="baz"), WikilinkClose()]

---

name: comment_in_link_title
label: comments are valid in link titles
input: "[[foo<!--bar-->baz]]"
output: [WikilinkOpen(), Text(text="foo"), CommentStart(), Text(text="bar"), CommentEnd(), Text(text="baz"), WikilinkClose()]

---

name: incomplete_comment_in_link_title
label: incomplete comments are invalid in link titles
input: "[[foo<!--bar--baz]]"
output: [Text(text="[[foo<!--bar--baz]]")]

---

name: incomplete_comment_in_link_title_2
label: incomplete comments are invalid in link titles
input: "[[foo<!--barbaz]]"
output: [Text(text="[[foo<!--barbaz]]")]

---

name: incomplete_comment_in_link_title_3
label: incomplete comments are invalid in link titles
input: "[[foo<!barbaz]]"
output: [Text(text="[[foo<!barbaz]]")]

---

name: incomplete_comment_in_link_title_4
label: incomplete comments are invalid in link titles
input: "[[foo<!--]]"
output: [Text(text="[[foo<!--]]")]

---

name: incomplete_comment_in_link_title_5
label: incomplete comments are invalid in link titles
input: "[[foo<!-"
output: [Text(text="[[foo<!-")]

---

name: incomplete_comment_in_link_title_6
label: incomplete comments are invalid in link titles
input: "[[foo<!--bar"
output: [Text(text="[[foo<!--bar")]

+ 14
- 0
tests/tokenizer/templates.mwtest Dosyayı Görüntüle

@@ -509,6 +509,20 @@ output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="

---

name: invalid_left_angle_bracket
label: invalid template: left angle bracket in name
input: "{{foo<bar}}"
output: [Text(text="{{foo<bar}}")]

---

name: invalid_right_angle_bracket
label: invalid template: right angle bracket in name
input: "{{foo>bar}}"
output: [Text(text="{{foo>bar}}")]

---

name: incomplete_stub
label: incomplete templates that should fail gracefully: just an opening
input: "{{"


+ 28
- 0
tests/tokenizer/wikilinks.mwtest Dosyayı Görüntüle

@@ -124,6 +124,34 @@ output: [Text(text="[[foo|"), WikilinkOpen(), Text(text="bar"), WikilinkClose()]

---

name: invalid_left_angle_bracket
label: invalid wikilink: left angle bracket
input: "[[foo<bar]]"
output: [Text(text="[[foo<bar]]")]

---

name: invalid_right_angle_bracket
label: invalid wikilink: right angle bracket
input: "[[foo>bar]]"
output: [Text(text="[[foo>bar]]")]

---

name: invalid_newline_at_start
label: invalid wikilink: newline at start of title
input: "[[\nfoobar]]"
output: [Text(text="[[\nfoobar]]")]

---

name: invalid_newline_at_end
label: invalid wikilink: newline at end of title
input: "[[foobar\n]]"
output: [Text(text="[[foobar\n]]")]

---

name: incomplete_open_only
label: incomplete wikilinks: just an open
input: "[["


Yükleniyor…
İptal
Kaydet