trac-wiki 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/trac-wiki/parser.rb +11 -1
- data/lib/trac-wiki/version.rb +1 -1
- data/test/parser_test.rb +7 -0
- metadata +2 -2
data/lib/trac-wiki/parser.rb
CHANGED
@@ -53,6 +53,11 @@ module TracWiki
|
|
53
53
|
attr_writer :no_escape
|
54
54
|
def no_escape?; @no_escape; end
|
55
55
|
|
56
|
+
# Disable url escaping for local links
|
57
|
+
# [[whatwerver]] stays [[whatwerver]]
|
58
|
+
attr_writer :no_link
|
59
|
+
def no_link?; @no_link; end
|
60
|
+
|
56
61
|
# Create a new Parser instance.
|
57
62
|
def initialize(text, options = {})
|
58
63
|
@allowed_schemes = %w(http https ftp ftps)
|
@@ -260,17 +265,22 @@ module TracWiki
|
|
260
265
|
end
|
261
266
|
|
262
267
|
def make_link(link, content, whole)
|
263
|
-
uri = make_explicit_link(link)
|
264
268
|
# specail "link" [[BR]]:
|
265
269
|
if link =~ /^br$/i
|
266
270
|
@out << '<br/>'
|
267
271
|
return
|
268
272
|
end
|
273
|
+
uri = make_explicit_link(link)
|
269
274
|
if not uri
|
270
275
|
@out << escape_html(whole)
|
271
276
|
return
|
272
277
|
end
|
273
278
|
|
279
|
+
if no_link?
|
280
|
+
@out << escape_html(whole)
|
281
|
+
return
|
282
|
+
end
|
283
|
+
|
274
284
|
make_explicit_link(link)
|
275
285
|
@out << '<a href="' << escape_html(uri) << '">'
|
276
286
|
if content
|
data/lib/trac-wiki/version.rb
CHANGED
data/test/parser_test.rb
CHANGED
@@ -11,6 +11,11 @@ class Bacon::Context
|
|
11
11
|
end
|
12
12
|
|
13
13
|
describe TracWiki::Parser do
|
14
|
+
it 'should not parse linkd' do
|
15
|
+
tc "<p>[[ahoj]]</p>\n", "[[ahoj]]", :no_link => true
|
16
|
+
tc "<p>[[ahoj|bhoj]]</p>\n", "[[ahoj|bhoj]]", :no_link => true
|
17
|
+
tc "<ul><li>[[ahoj|bhoj]]</li></ul>", "* [[ahoj|bhoj]]", :no_link => true
|
18
|
+
end
|
14
19
|
it 'should parse bold' do
|
15
20
|
# Bold can be used inside paragraphs
|
16
21
|
tc "<p>This <strong>is</strong> bold</p>\n", "This **is** bold"
|
@@ -443,7 +448,9 @@ describe TracWiki::Parser do
|
|
443
448
|
|
444
449
|
# Image tags should be escape
|
445
450
|
tc("<p><img src=\"image.jpg\"/></p>\n", "[[Image(image.jpg)]]")
|
451
|
+
tc("<p><img src=\"image.jpg\"/></p>\n", "[[Image(image.jpg)]]", :no_link=>true)
|
446
452
|
tc("<p><img src=\"image.jpg\" alt=\""tag"\"/></p>\n", "[[Image(image.jpg|\"tag\")]]")
|
453
|
+
tc("<p><img src=\"image.jpg\" alt=\""tag"\"/></p>\n", "[[Image(image.jpg|\"tag\")]]", :no_link=>true)
|
447
454
|
|
448
455
|
# Malicious links should not be converted.
|
449
456
|
tc("<p><a href=\"javascript%3Aalert%28%22Boo%21%22%29\">Click</a></p>\n", "[[javascript:alert(\"Boo!\")|Click]]")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trac-wiki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bacon
|