Validate bounds just to be sure

This commit is contained in:
Douwe Maan 2016-01-20 19:33:34 +01:00
parent 0e992a3b4e
commit 6000f8545f
1 changed files with 3 additions and 0 deletions

View File

@ -93,6 +93,9 @@ module Gitlab
# Inserts tags around the characters identified by the given range
def insert_around_range(text, range, before, after, offset = 0)
# Just to be sure
return offset if offset + range.end + 1 > text.length
text.insert(offset + range.begin, before)
offset += before.length