You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2021/10/18 10:38:13 UTC
[Bug 65638] New: [PATCH] Remove escaping of ampersand from headers
and footers created by Excel
https://bz.apache.org/bugzilla/show_bug.cgi?id=65638
Bug ID: 65638
Summary: [PATCH] Remove escaping of ampersand from headers and
footers created by Excel
Product: POI
Version: 5.0.x-dev
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P2
Component: XSSF
Assignee: dev@poi.apache.org
Reporter: viru.gajanayake@yahoo.com
Target Milestone: ---
In Excel headers and footers (both .xls and .xlsx) an ampersand "&" is used as
the start of formatting fields. If a user wants to enter an ampersand as text
in a header, they need to "escape" it as "&&". In order words to display "&"
in a header you need to enter "&&". This patch removes that escaping when
removing other formatting via another regex in
org.apache.poi.hssf.usermodel.HeaderFooter.stripFields()
text = text.replaceAll("&&", "&");
Also, in the existing code the string which defines the regex has a backslash
before the ampersand.
text = text.replaceAll("\\&\\d+", "");
The ampersand in the regex does not need to be escaped, it can be written as:
text = text.replaceAll("&\\d+", "");
The backslash has been removed in 4 lines to make the new line consistent with
the existing ones.
The patch contains a .xls and a .xlsx file produced in Excel with a header that
displays as "one & two &&" and is used for unit testing.
Two existing unit tests have also been corrected which were previously
confirming the incorrect behaviour. These appear to be tests generated by
examining the code rather than seeing what Excel generates.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 65638] [PATCH] Remove escaping of ampersand from headers and
footers created by Excel
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65638
--- Comment #1 from Viru <vi...@yahoo.com> ---
Created attachment 38072
--> https://bz.apache.org/bugzilla/attachment.cgi?id=38072&action=edit
Patch
tar.gz containing the patch and test files as described
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 65638] [PATCH] Remove escaping of ampersand from headers and
footers created by Excel
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65638
PJ Fanning <fa...@yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 65638] [PATCH] Remove escaping of ampersand from headers and
footers created by Excel
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65638
--- Comment #2 from PJ Fanning <fa...@yahoo.com> ---
Thanks - applied using r1894357
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org