wikitext 4.8 → 4.9
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.
- checksums.yaml +4 -4
- data/ext/wikitext/parser.c +17 -4
- data/ext/wikitext/ruby_compat.h +4 -0
- data/ext/wikitext/wikitext.c +5 -21
- data/lib/wikitext/version.rb +1 -1
- data/spec/external_link_spec.rb +2 -2
- data/spec/regressions_spec.rb +13 -13
- metadata +7 -24
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ed3e58945b3689bd970b458d92a8a041b31dc6c0c83378e8b0409c4b46c0fa9d
|
|
4
|
+
data.tar.gz: 17cb2780a9034593794d92c91c6388e0249e44cb1f14d98807a147508b4b1811
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3a550d41ebe0a3a1ccd02613b3834765e8c3c2aae8b9c8de34dbf69ae7c11e240652e347a76098416d6d46ab7ddd9d2b397012d8af8946112c33175a60f802ed
|
|
7
|
+
data.tar.gz: adac43e11f069a88853448cd62ae3271d889d6e1a48fd385d76aa56e34f07af3f3c3bdee413300038ce381194e4a4adac9628a6b168e573dcafcd3fa13cc00bb
|
data/ext/wikitext/parser.c
CHANGED
|
@@ -2585,16 +2585,29 @@ VALUE Wikitext_parser_parse(int argc, VALUE *argv, VALUE self)
|
|
|
2585
2585
|
// reset current token; forcing lexer to return another token at the top of the loop
|
|
2586
2586
|
token = NULL;
|
|
2587
2587
|
} while (1);
|
|
2588
|
+
|
|
2588
2589
|
return_output:
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2590
|
+
str_append(parser->output, null_str, 1); // Null-terminate.
|
|
2591
|
+
#if defined(RUBY_API_VERSION_CODE) && RUBY_API_VERSION_CODE >= 30200
|
|
2592
|
+
// Ruby string internals changed around 3.2, ending the 14-year non-breaking
|
|
2593
|
+
// streak mentioned in 10808fef5921b7acff203da4fdaa0fdbaec2f603.
|
|
2594
|
+
//
|
|
2595
|
+
// Instead of hackily trying to avoid a reallocation, just eat the cost and
|
|
2596
|
+
// create a new string (Ruby will copy the data). Ruby has gotten faster
|
|
2597
|
+
// over the years anyway, and we can hope that the cost of parsing outweighs
|
|
2598
|
+
// the allocation and copying.
|
|
2599
|
+
return rb_str_new(parser->output->ptr, parser->output->len - 1);
|
|
2600
|
+
#else
|
|
2601
|
+
// Nasty hack to avoid re-allocating our return value by reaching into Ruby
|
|
2602
|
+
// string internals.
|
|
2603
|
+
len = parser->output->len - 1; // Don't count null termination.
|
|
2592
2604
|
|
|
2593
2605
|
VALUE out = rb_str_buf_new(RSTRING_EMBED_LEN_MAX + 1);
|
|
2594
2606
|
free(RSTRING_PTR(out));
|
|
2595
2607
|
RSTRING(out)->as.heap.aux.capa = len;
|
|
2596
2608
|
RSTRING(out)->as.heap.ptr = parser->output->ptr;
|
|
2597
2609
|
RSTRING(out)->as.heap.len = len;
|
|
2598
|
-
parser->output->ptr = NULL; //
|
|
2610
|
+
parser->output->ptr = NULL; // Don't double-free.
|
|
2599
2611
|
return out;
|
|
2612
|
+
#endif
|
|
2600
2613
|
}
|
data/ext/wikitext/ruby_compat.h
CHANGED
data/ext/wikitext/wikitext.c
CHANGED
|
@@ -35,30 +35,13 @@ VALUE cWikitextParserToken = 0; // class Wikitext::Parser::Token
|
|
|
35
35
|
// require 'wikitext/rails_template_handler'
|
|
36
36
|
// end
|
|
37
37
|
//
|
|
38
|
-
//
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
// First we have wikitext_on_load_block(), which is a function which defines
|
|
42
|
-
// the "block" of code that we want to have evaluated.
|
|
43
|
-
//
|
|
44
|
-
// To actually pass this block in to the ActiveSupport::on_load method we
|
|
45
|
-
// need the help of an intermediate helper function,
|
|
46
|
-
// wikitext_block_forwarder(), which we invoke with the aid of rb_iterate()
|
|
47
|
-
// later on.
|
|
48
|
-
//
|
|
49
|
-
// This works because the rb_funcall() function in wikitext_block_forwarder()
|
|
50
|
-
// propagates the block through to the called method.
|
|
51
|
-
VALUE wikitext_on_load_block(VALUE yielded, VALUE other)
|
|
38
|
+
// We use rb_block_call to call the on_load method with a block.
|
|
39
|
+
// The wikitext_on_load_block() function defines the block code.
|
|
40
|
+
VALUE wikitext_on_load_block(VALUE yielded, VALUE data, int argc, const VALUE *argv, VALUE blockarg)
|
|
52
41
|
{
|
|
53
42
|
return rb_require("wikitext/rails_template_handler");
|
|
54
43
|
}
|
|
55
44
|
|
|
56
|
-
VALUE wikitext_block_forwarder(VALUE receiver)
|
|
57
|
-
{
|
|
58
|
-
return rb_funcall(receiver, rb_intern("on_load"), 1,
|
|
59
|
-
ID2SYM(rb_intern("action_view")));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
45
|
void Init_wikitext()
|
|
63
46
|
{
|
|
64
47
|
// Wikitext
|
|
@@ -112,7 +95,8 @@ void Init_wikitext()
|
|
|
112
95
|
|
|
113
96
|
VALUE active_support = rb_const_get(rb_cObject,
|
|
114
97
|
rb_intern("ActiveSupport"));
|
|
115
|
-
|
|
98
|
+
VALUE arg = ID2SYM(rb_intern("action_view"));
|
|
99
|
+
rb_block_call(active_support, rb_intern("on_load"), 1, &arg,
|
|
116
100
|
wikitext_on_load_block, Qnil);
|
|
117
101
|
}
|
|
118
102
|
}
|
data/lib/wikitext/version.rb
CHANGED
data/spec/external_link_spec.rb
CHANGED
|
@@ -59,7 +59,7 @@ describe Wikitext::Parser, 'external links' do
|
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
it 'formats external mailto links where the linktext is itself an email' do
|
|
62
|
-
# reported here: https://wincent.
|
|
62
|
+
# reported here: https://wincent.dev/issues/1955
|
|
63
63
|
expected = %{<p><a href="mailto:user@example.com" class="mailto">user@example.com</a></p>\n}
|
|
64
64
|
@parser.parse('[mailto:user@example.com user@example.com]').should == expected
|
|
65
65
|
|
|
@@ -71,7 +71,7 @@ describe Wikitext::Parser, 'external links' do
|
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
it 'allows email addreses in link text' do
|
|
74
|
-
# more general case of bug reported here: https://wincent.
|
|
74
|
+
# more general case of bug reported here: https://wincent.dev/issues/1955
|
|
75
75
|
expected = %{<p><a href="http://google.com/?q=user@example.com" class="external">Google for user@example.com</a></p>\n}
|
|
76
76
|
@parser.parse('[http://google.com/?q=user@example.com Google for user@example.com]').should == expected
|
|
77
77
|
end
|
data/spec/regressions_spec.rb
CHANGED
|
@@ -50,7 +50,7 @@ describe Wikitext::Parser, 'regressions' do
|
|
|
50
50
|
@parser.parse(input).should == expected
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
-
# discovered at:
|
|
53
|
+
# discovered at: https://wincent.dev/wiki/nginx_log_rotation
|
|
54
54
|
# fixed by 0a328f1
|
|
55
55
|
it 'should allow empty lines in PRE blocks marked up with a leading space' do
|
|
56
56
|
input = dedent <<-END
|
|
@@ -70,7 +70,7 @@ describe Wikitext::Parser, 'regressions' do
|
|
|
70
70
|
@parser.parse(input).should == expected
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
-
# discovered at:
|
|
73
|
+
# discovered at: https://wincent.dev/wiki/Installing_Ragel_5.2.0_on_Mac_OS_X_Tiger
|
|
74
74
|
# fixed by a616841
|
|
75
75
|
it 'should handle PRE_START blocks which follow unordered lists' do
|
|
76
76
|
input = dedent <<-END
|
|
@@ -91,7 +91,7 @@ describe Wikitext::Parser, 'regressions' do
|
|
|
91
91
|
@parser.parse(input).should == expected
|
|
92
92
|
end
|
|
93
93
|
|
|
94
|
-
# discovered at:
|
|
94
|
+
# discovered at: https://wincent.dev/wiki/Movable_Type_security_notes
|
|
95
95
|
# fixed by a616841
|
|
96
96
|
it 'should handle PRE_START blocks which follow ordered lists' do
|
|
97
97
|
input = dedent <<-END
|
|
@@ -108,7 +108,7 @@ describe Wikitext::Parser, 'regressions' do
|
|
|
108
108
|
@parser.parse(input).should == expected
|
|
109
109
|
end
|
|
110
110
|
|
|
111
|
-
# discovered at:
|
|
111
|
+
# discovered at: https://wincent.dev/wiki/Movable_Type_security_notes
|
|
112
112
|
# fixed by 191b75d
|
|
113
113
|
it 'should respect additional indentation found inside PRE blocks' do
|
|
114
114
|
# note the two extra spaces on each line
|
|
@@ -752,7 +752,7 @@ describe Wikitext::Parser, 'regressions' do
|
|
|
752
752
|
@parser.parse(input).should == expected
|
|
753
753
|
end
|
|
754
754
|
|
|
755
|
-
# discovered at:
|
|
755
|
+
# discovered at: https://wincent.dev/wiki/Testing_cookies_in_Rails
|
|
756
756
|
it 'should handle BLOCKQUOTE_START blocks which follow lists' do
|
|
757
757
|
# example text taken from wiki article and edited for brevity
|
|
758
758
|
input = dedent <<-END
|
|
@@ -770,7 +770,7 @@ describe Wikitext::Parser, 'regressions' do
|
|
|
770
770
|
@parser.parse(input).should == expected
|
|
771
771
|
end
|
|
772
772
|
|
|
773
|
-
# https://wincent.
|
|
773
|
+
# https://wincent.dev/issues/818
|
|
774
774
|
it 'should handle BLOCKQUOTE_START blocks which follow BLOCKQUOTE shorthand' do
|
|
775
775
|
input = dedent <<-END
|
|
776
776
|
> foo
|
|
@@ -787,7 +787,7 @@ describe Wikitext::Parser, 'regressions' do
|
|
|
787
787
|
@parser.parse(input).should == expected
|
|
788
788
|
end
|
|
789
789
|
|
|
790
|
-
# https://wincent.
|
|
790
|
+
# https://wincent.dev/issues/818
|
|
791
791
|
it 'should handle PRE_START blocks which follow BLOCKQUOTE shorthand' do
|
|
792
792
|
input = dedent <<-END
|
|
793
793
|
> foo
|
|
@@ -802,7 +802,7 @@ describe Wikitext::Parser, 'regressions' do
|
|
|
802
802
|
@parser.parse(input).should == expected
|
|
803
803
|
end
|
|
804
804
|
|
|
805
|
-
# https://wincent.
|
|
805
|
+
# https://wincent.dev/issues/818
|
|
806
806
|
it 'should handle BLOCKQUOTE_START blocks which follow nested BLOCKQUOTE shorthand' do
|
|
807
807
|
input = dedent <<-END
|
|
808
808
|
>>> foo
|
|
@@ -823,7 +823,7 @@ describe Wikitext::Parser, 'regressions' do
|
|
|
823
823
|
@parser.parse(input).should == expected
|
|
824
824
|
end
|
|
825
825
|
|
|
826
|
-
# https://wincent.
|
|
826
|
+
# https://wincent.dev/issues/818
|
|
827
827
|
it 'should handle PRE_START blocks which follow nested BLOCKQUOTE shorthand' do
|
|
828
828
|
input = dedent <<-END
|
|
829
829
|
>>> foo
|
|
@@ -842,7 +842,7 @@ describe Wikitext::Parser, 'regressions' do
|
|
|
842
842
|
@parser.parse(input).should == expected
|
|
843
843
|
end
|
|
844
844
|
|
|
845
|
-
# https://wincent.
|
|
845
|
+
# https://wincent.dev/issues/1289
|
|
846
846
|
it 'should handle empty (zero-width) link targets' do
|
|
847
847
|
# these were badly broken (caused exceptions to be raised)
|
|
848
848
|
@parser.parse('[[]]').should == "<p>[[]]</p>\n"
|
|
@@ -864,7 +864,7 @@ describe Wikitext::Parser, 'regressions' do
|
|
|
864
864
|
@parser.parse('[[ |foo]]').should == "<p>[[ |foo]]</p>\n"
|
|
865
865
|
end
|
|
866
866
|
|
|
867
|
-
# first manifested itself in this comment: https://wincent.
|
|
867
|
+
# first manifested itself in this comment: https://wincent.dev/comments/6427
|
|
868
868
|
it 'handles "`[/`"' do
|
|
869
869
|
# This is, of course, an invalid link, but it could be handled more
|
|
870
870
|
# gracefully (we were opening a <code> span and instead of just rolling
|
|
@@ -877,7 +877,7 @@ describe Wikitext::Parser, 'regressions' do
|
|
|
877
877
|
# PATH sequence (any such token would just be dropped on the floor).
|
|
878
878
|
@parser.parse('with `[/` then').should == "<p>with <code>[/</code> then</p>\n"
|
|
879
879
|
|
|
880
|
-
# related example from the original ticket: https://wincent.
|
|
880
|
+
# related example from the original ticket: https://wincent.dev/issues/1726
|
|
881
881
|
@parser.parse('[/bar?baz=bat link]').should == "<p>[/bar?baz=bat link]</p>\n"
|
|
882
882
|
end
|
|
883
883
|
|
|
@@ -890,7 +890,7 @@ describe Wikitext::Parser, 'regressions' do
|
|
|
890
890
|
@parser.parse('[http://foo.com]').should == expected
|
|
891
891
|
end
|
|
892
892
|
|
|
893
|
-
# https://wincent.
|
|
893
|
+
# https://wincent.dev/issues/1891
|
|
894
894
|
it 'handles shorthand PRE blocks containing lines starting with slashes' do
|
|
895
895
|
expected = "<pre>/a\n/b\n/c</pre>\n"
|
|
896
896
|
@parser.parse(" /a\n /b\n /c").should == expected
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: wikitext
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '4.
|
|
4
|
+
version: '4.9'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Greg Hurrell
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rake
|
|
@@ -16,42 +15,28 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - "~>"
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
18
|
+
version: '13.0'
|
|
20
19
|
type: :development
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
23
|
- - "~>"
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
25
|
+
version: '13.0'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
27
|
name: rspec
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
30
29
|
requirements:
|
|
31
30
|
- - "~>"
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
32
|
+
version: '3.0'
|
|
34
33
|
type: :development
|
|
35
34
|
prerelease: false
|
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
36
|
requirements:
|
|
38
37
|
- - "~>"
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: thor
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - "~>"
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: 0.17.0
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - "~>"
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: 0.17.0
|
|
39
|
+
version: '3.0'
|
|
55
40
|
- !ruby/object:Gem::Dependency
|
|
56
41
|
name: yard
|
|
57
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -152,7 +137,6 @@ homepage: https://github.com/wincent/wikitext
|
|
|
152
137
|
licenses:
|
|
153
138
|
- BSD-2-Clause
|
|
154
139
|
metadata: {}
|
|
155
|
-
post_install_message:
|
|
156
140
|
rdoc_options: []
|
|
157
141
|
require_paths:
|
|
158
142
|
- ext
|
|
@@ -168,8 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
168
152
|
- !ruby/object:Gem::Version
|
|
169
153
|
version: '0'
|
|
170
154
|
requirements: []
|
|
171
|
-
rubygems_version: 3.
|
|
172
|
-
signing_key:
|
|
155
|
+
rubygems_version: 3.6.9
|
|
173
156
|
specification_version: 4
|
|
174
157
|
summary: Wikitext-to-HTML translator
|
|
175
158
|
test_files: []
|