ruby-bbcode-to-md 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
data/lib/ruby-bbcode-to-md.rb
CHANGED
@@ -20,6 +20,10 @@ module RubyBBCode
|
|
20
20
|
@ignore_validation = false
|
21
21
|
end
|
22
22
|
|
23
|
+
def validation_enabled
|
24
|
+
!@ignore_validation.nil? and !@ignore_validation
|
25
|
+
end
|
26
|
+
|
23
27
|
# This method converts the given text (with BBCode tags) into a HTML representation
|
24
28
|
# The escape_html parameter (default: true) escapes HTML tags that were present in the given text and therefore blocking (mallicious) HTML in the original text
|
25
29
|
# The additional_tags parameter is used to add additional BBCode tags that should be accepted
|
@@ -146,7 +146,7 @@ module RubyBBCode
|
|
146
146
|
end
|
147
147
|
|
148
148
|
def valid_text_or_opening_element?
|
149
|
-
if
|
149
|
+
if RubyBBCode.validation_enabled and @ti.element_is_text? or @ti.element_is_opening_tag?
|
150
150
|
return false if validate_opening_tag == false
|
151
151
|
return false if validate_constraints_on_child == false
|
152
152
|
end
|
@@ -155,7 +155,7 @@ module RubyBBCode
|
|
155
155
|
|
156
156
|
def validate_opening_tag
|
157
157
|
# TODO: rename this if statement to #validate_opening_tag
|
158
|
-
if
|
158
|
+
if RubyBBCode.validation_enabled and @ti.element_is_opening_tag?
|
159
159
|
unless @ti.allowed_outside_parent_tags? or (within_open_tag? and @ti.allowed_in(parent_tag.to_sym))
|
160
160
|
# Tag doesn't belong in the last opened tag
|
161
161
|
throw_child_requires_specific_parent_error; return false
|
@@ -174,7 +174,7 @@ module RubyBBCode
|
|
174
174
|
|
175
175
|
def validate_constraints_on_child
|
176
176
|
# TODO: Rename this if statement to #validate_constraints_on_child
|
177
|
-
if
|
177
|
+
if RubyBBCode.validation_enabled and within_open_tag? and parent_has_constraints_on_children?
|
178
178
|
# Check if the found tag is allowed
|
179
179
|
last_tag = @dictionary[parent_tag]
|
180
180
|
allowed_tags = last_tag[:only_allow]
|
@@ -189,7 +189,7 @@ module RubyBBCode
|
|
189
189
|
def valid_closing_element?
|
190
190
|
tag = @ti.definition
|
191
191
|
|
192
|
-
if
|
192
|
+
if RubyBBCode.validation_enabled and @ti.element_is_closing_tag?
|
193
193
|
if parent_tag != @ti[:tag].to_sym
|
194
194
|
@errors = ["Closing tag [/#{@ti[:tag]}] does match [#{parent_tag}]"]
|
195
195
|
return false
|
@@ -211,7 +211,7 @@ module RubyBBCode
|
|
211
211
|
tag = @bbtree.current_node.definition
|
212
212
|
|
213
213
|
# this conditional ensures whether the validation is apropriate to this tag type
|
214
|
-
if
|
214
|
+
if RubyBBCode.validation_enabled and @ti.element_is_text? and within_open_tag? and tag[:require_between] and candidate_for_using_between_as_param?
|
215
215
|
|
216
216
|
# check if valid
|
217
217
|
if @ti[:text].match(tag[:tag_param]).nil?
|
@@ -224,7 +224,7 @@ module RubyBBCode
|
|
224
224
|
|
225
225
|
def validate_all_tags_closed_off
|
226
226
|
# if we're still expecting a closing tag and we've come to the end of the string... throw error
|
227
|
-
throw_unexpected_end_of_string_error if expecting_a_closing_tag? and
|
227
|
+
throw_unexpected_end_of_string_error if expecting_a_closing_tag? and RubyBBCode.validation_enabled
|
228
228
|
end
|
229
229
|
|
230
230
|
def validate_stack_level_too_deep_potential
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-bbcode-to-md
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -108,7 +108,7 @@ rubyforge_project:
|
|
108
108
|
rubygems_version: 1.8.23
|
109
109
|
signing_key:
|
110
110
|
specification_version: 3
|
111
|
-
summary: ruby-bbcode-to-md-0.0.
|
111
|
+
summary: ruby-bbcode-to-md-0.0.9
|
112
112
|
test_files:
|
113
113
|
- test/ruby_bbcode_test.rb
|
114
114
|
- test/test_helper.rb
|