Skip to content

Commit

Permalink
Fix out-of-memory issue with some message texts in HtmlFormatter#repl…
Browse files Browse the repository at this point in the history
…ace_urls [#75]
  • Loading branch information
tvdstaaij committed Mar 5, 2017
1 parent 601b776 commit 4193731
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions formatters/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,11 @@ def replace_urls(text)
# TODO: IP addresses. IPv6 addresses. I completely forgot about those.

urls = text.scan(/(^|\s|<)(([a-zA-Z]{1,25}:)?([^@\s]{1,200}@)?(\/\/)?([0-9a-zA-Z][a-zA-Z0-9-]{0,63}\.){0,125}[a-zA-Z][a-zA-Z0-9-]{0,63}\.([a-zA-Z]{2,63}|xn--[a-zA-Z0-9]{1,60})(:[1-9][0-9]{0,4})?(\/[!-~]*)?(\s|>|$|\)|\.))/)

.map { |arr| arr[1] }
.uniq
text = CGI::escapeHTML(text)

urls.each do |url|
url = url[1]
escaped_url = CGI::escapeHTML(url)

if text.index(escaped_url) == nil
Expand Down

0 comments on commit 4193731

Please sign in to comment.