From 602f06cfb1079cb0153acba75dd94140c58d7b7b Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 23 May 2018 19:53:21 +0000 Subject: [xfa] Skip text length check for empty text fields This CL sets the text edit engine to skip the length check when doing an insert if the engine is currently empty. This allows handling inserting the formatted version of strings if they have a length longer then the maximium length. Bug: 1066 Change-Id: If9799334f889b8ae0f568f1f9d5457e2b504aa1d Reviewed-on: https://pdfium-review.googlesource.com/32898 Commit-Queue: Ryan Harrison Reviewed-by: Ryan Harrison --- xfa/fde/cfde_texteditengine.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/xfa/fde/cfde_texteditengine.cpp b/xfa/fde/cfde_texteditengine.cpp index 87dba53158..3363baa0cd 100644 --- a/xfa/fde/cfde_texteditengine.cpp +++ b/xfa/fde/cfde_texteditengine.cpp @@ -274,7 +274,14 @@ void CFDE_TextEditEngine::Insert(size_t idx, // If we're going to be too big we insert what we can and notify the // delegate we've filled the text after the insert is done. bool exceeded_limit = false; - if (has_character_limit_ && text_length_ + length > character_limit_) { + + // Currently we allow inserting a number of characters over the text limit if + // the text edit is already empty. This allows supporting text fields which + // do formatting. Otherwise, if you enter 123456789 for an SSN into a field + // with a 9 character limit and we reformat to 123-45-6789 we'll truncate + // the 89 when inserting into the text edit. See https://crbug.com/pdfium/1089 + if (has_character_limit_ && text_length_ > 0 && + text_length_ + length > character_limit_) { exceeded_limit = true; length = character_limit_ - text_length_; } -- cgit v1.2.3