Skip to content

Commit d2e705e

Browse files
author
Ian Clarkson
committed
Check size in bytes as opposed to string size
size returns length in characters, but doesn't factor in multibyte Unicode characters. By switching to bytesize, we check the relevant measure of how many bytes the worksheet name is. Fixes #588.
1 parent c593a08 commit d2e705e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/axlsx/workbook/worksheet/worksheet.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ def outline(collection, range, level = 1, collapsed = true)
656656

657657
def validate_sheet_name(name)
658658
DataTypeValidator.validate :worksheet_name, String, name
659-
raise ArgumentError, (ERR_SHEET_NAME_TOO_LONG % name) if name.size > 31
659+
raise ArgumentError, (ERR_SHEET_NAME_TOO_LONG % name) if name.bytesize > 31
660660
raise ArgumentError, (ERR_SHEET_NAME_CHARACTER_FORBIDDEN % name) if '[]*/\?:'.chars.any? { |char| name.include? char }
661661
name = Axlsx::coder.encode(name)
662662
sheet_names = @workbook.worksheets.reject { |s| s == self }.map { |s| s.name }

0 commit comments

Comments
 (0)