diff options
-rw-r--r-- | lib/VNDB/BBCode.pm | 4 | ||||
-rwxr-xr-x | util/bbcode-test.pl | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/VNDB/BBCode.pm b/lib/VNDB/BBCode.pm index 95a90d16..b95ef760 100644 --- a/lib/VNDB/BBCode.pm +++ b/lib/VNDB/BBCode.pm @@ -118,8 +118,8 @@ sub parse { (?:https?|ftp)://[^><"\n\s\]\[]+[\d\w=/-] # link )}xg) { my $token = $&; - my $pre = substr $raw, $last, (pos($raw)-length($&))-$last; - my $char_pre = $last ? substr $raw, pos($raw)-length($&)-1, 1 : ''; + my $pre = substr $raw, $last, $-[0]-$last; + my $char_pre = $-[0] ? substr $raw, $-[0]-1, 1 : ''; $last = pos $raw; my $char_post = substr $raw, $last, 1; diff --git a/util/bbcode-test.pl b/util/bbcode-test.pl index 1b8650cf..07133aca 100755 --- a/util/bbcode-test.pl +++ b/util/bbcode-test.pl @@ -109,6 +109,11 @@ my @tests = ( '<a href="/v17">v17</a> text dds16v21 more text1 <a href="/v9">v9</a>', 'v17 text dds16v21 more text1 v9', + # https://vndb.org/t2520.231 + 'pov1', + 'pov1', + 'pov1', + # Not sure what to do here #'http://some[raw].pointlessly[/raw].unusual.domain/', #'<a href="http://some.pointlessly.unusual.domain/" rel="nofollow">link</a>', |