File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -51,13 +51,13 @@ class HTML < Basic
51
51
def set_color ( string , *colors )
52
52
if colors . all? { |color | color . is_a? ( Symbol ) || color . is_a? ( String ) }
53
53
html_colors = colors . map { |color | lookup_color ( color ) }
54
- "<span style=\" #{ html_colors . join ( '; ' ) } ;\" >#{ CGI . escapeHTML ( string ) } </span>"
54
+ "<span style=\" #{ html_colors . join ( '; ' ) } ;\" >#{ Thor :: Util . escape_html ( string ) } </span>"
55
55
else
56
56
color , bold = colors
57
57
html_color = self . class . const_get ( color . to_s . upcase ) if color . is_a? ( Symbol )
58
58
styles = [ html_color ]
59
59
styles << BOLD if bold
60
- "<span style=\" #{ styles . join ( '; ' ) } ;\" >#{ CGI . escapeHTML ( string ) } </span>"
60
+ "<span style=\" #{ styles . join ( '; ' ) } ;\" >#{ Thor :: Util . escape_html ( string ) } </span>"
61
61
end
62
62
end
63
63
Original file line number Diff line number Diff line change @@ -263,6 +263,22 @@ def ruby_command
263
263
def escape_globs ( path )
264
264
path . to_s . gsub ( /[*?{}\[ \] ]/ , '\\\\\\&' )
265
265
end
266
+
267
+ # Returns a string that has had any HTML characters escaped.
268
+ #
269
+ # ==== Examples
270
+ #
271
+ # Thor::Util.escape_html('<div>') # => "<div>"
272
+ #
273
+ # ==== Parameters
274
+ # String
275
+ #
276
+ # ==== Returns
277
+ # String
278
+ #
279
+ def escape_html ( string )
280
+ CGI . escapeHTML ( string )
281
+ end
266
282
end
267
283
end
268
284
end
You can’t perform that action at this time.
0 commit comments