summaryrefslogtreecommitdiff
path: root/xfa/fde
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-05-23 19:53:21 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-23 19:53:21 +0000
commit602f06cfb1079cb0153acba75dd94140c58d7b7b (patch)
tree7ffea69ec92a75c73c896814d295d09533a8dbbc /xfa/fde
parentd0f10a8240c2b68f8536ac0729b811088c13051a (diff)
downloadpdfium-602f06cfb1079cb0153acba75dd94140c58d7b7b.tar.xz
[xfa] Skip text length check for empty text fieldschromium/3439
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 <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa/fde')
-rw-r--r--xfa/fde/cfde_texteditengine.cpp9
1 files changed, 8 insertions, 1 deletions
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_;
}