[Bug 64788] New: Text validation in createPromptBox doesn't read _x000a_ line break as one caracter

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug 64788] New: Text validation in createPromptBox doesn't read _x000a_ line break as one caracter

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=64788

            Bug ID: 64788
           Summary: Text validation in createPromptBox doesn't read
                    _x000a_ line break as one caracter
           Product: POI
           Version: 4.1.2-FINAL
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: XSSF
          Assignee: [hidden email]
          Reporter: [hidden email]
  Target Milestone: ---

Currently a data validation occuring in createPromptBox on the prompt text is
checking whether text is longuer than 255 omiting the fact that line break
entities are transcoded as _x000a_ text and thus failing the test while in
reality  _x000a_ is seens as 1 caracter by excel.

As a solution you may check length on a string wich is obtained by replacing
_x000a_ or _x000a_ and _x000d_  as a dummy character before testing its length
against the 255 caracters limit :

if(text != null && text.length() > 255) {
                        throw new IllegalStateException("Prompt-text cannot be
longer than 255 characters, but had: " + text);
}

===>

if(text != null && text.replace("_x000a_","_").replace("_x000d_","_").length()
> 255) {
                        throw new IllegalStateException("Prompt-text cannot be
longer than 255 characters, but had: " + text);
}

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 64788] Text validation in createPromptBox doesn't read _x000a_ line break as one caracter

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=64788

--- Comment #1 from [hidden email] <[hidden email]> ---
I'm talking about org.apache.poi.hssf.usermodel.HSSFDataValidation class by the
way

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 64788] Text validation in createPromptBox doesn't read _x000a_ line break as one caracter

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=64788

--- Comment #2 from [hidden email] <[hidden email]> ---
and about org.apache.poi.hssf.usermodel.XSSFDataValidation class

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 64788] Text validation in createPromptBox doesn't read _x000a_ line break as one caracter

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=64788

--- Comment #3 from [hidden email] <[hidden email]> ---
Errr org.apache.poi.xssf.usermodel.XSSFDataValidation sorry

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 64788] Text validation in createPromptBox doesn't read _x000a_ line break as one caracter

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=64788

--- Comment #4 from [hidden email] <[hidden email]> ---
So for org.apache.poi.xssf.usermodel.XSSFDataValidation that might be more like
:

if(text != null && text.length() > MAX_TEXT_LENGTH) {
                        throw new IllegalStateException("Error-text cannot be
longer than 255 characters, but had: " + text);
}

===>

if(text != null && text.replace("_x000a_","_").replace("_x000d_","_").length()
> MAX_TEXT_LENGTH) {
                        throw new IllegalStateException("Error-text cannot be
longer than 255 characters, but had: " + text);
}

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 64788] Text validation in createPromptBox doesn't read _x000a_ line break as one caracter

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=64788

--- Comment #5 from PJ Fanning <[hidden email]> ---
it would probably be better to assume that all sequences like `_x000a_` are
counted as one char when getting the length

the 4 chars after the _x can be checked to see if they are valid hexadecimal
digits

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 64788] Text validation in createPromptBox doesn't read _x000a_ line break as one caracter

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=64788

--- Comment #6 from [hidden email] <[hidden email]> ---
Yeah that would be better as for example a regexp like

 .replaceAll("_x[0-9a-f]{4}_", "ยค")

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 64788] Text validation in createPromptBox doesn't read _x000a_ line break as one caracter

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=64788

[hidden email] <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
           Severity|major                       |trivial
           Priority|P2                          |P1
             Status|NEW                         |RESOLVED

--- Comment #7 from [hidden email] <[hidden email]> ---
Sorry I didn't saw that encodeUtf method was already converting \n to _x000a_
so I wasn't supposed to do it before calling setPrompt...

Sorry for the unconvenience...

Cheers

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]