Skip to content

Commit 8ee972c

Browse files
committed
FIX: bbcode codec must convert binary input to string before decoding
1 parent 3379198 commit 8ee972c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/mezz/codec-bbcode.reb

+7-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ REBOL [
22
Name: bbcode
33
Type: module
44
Options: [delay]
5-
Version: 0.3.0
5+
Version: 0.3.1
66
Title: "Codec: BBcode"
77
Purpose: {Basic BBCode implementation. For more info about BBCode check http://en.wikipedia.org/wiki/BBCode}
88
File: https://raw.githubusercontent.com/Oldes/Rebol3/master/src/mezz/codec-bbcode.reb
@@ -13,6 +13,7 @@ REBOL [
1313
0.2.0 19-Feb-2012 "review"
1414
0.2.1 22-Aug-2012 "added [hr] and [anchor]"
1515
0.3.0 24-Apr-2020 "ported to Rebol3"
16+
0.3.1 11-Dec-2023 "FIX: `bbcode` must accept only string input"
1617
]
1718
]
1819

@@ -195,7 +196,7 @@ enabled-tags: [
195196

196197
bbcode: func [
197198
"Converts BBCode markup into HTML"
198-
code [string! binary!] "Input with BBCode tags"
199+
code [string!] "Input with BBCode tags"
199200
/local tag err
200201
][
201202
err: try [
@@ -438,8 +439,10 @@ register-codec [
438439
/local result
439440
return: [string!]
440441
][
441-
if any [file? code url? code][code: read code]
442+
switch type?/word code [
443+
binary! [code: to string! code]
444+
file! url! [code: read/string code]
445+
]
442446
result: bbcode code
443-
444447
]
445448
]

src/tests/units/bbcode-test.r3

+3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ if find codecs 'BBCode [
8888
print "---"
8989
]
9090
]
91+
--test-- "bbcode with binary input"
92+
src: {text [b]bold[/b] abc}
93+
--assert (decode 'bbcode srt) = (decode 'bbcode to binary! src)
9194

9295
===end-group===
9396
]

0 commit comments

Comments
 (0)