[22/33] cxf git commit: [CXF-6989] Avoding a reg-ex split when processing Content-Disposition properties
[CXF-6989] Avoding a reg-ex split when processing Content-Disposition properties Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/34809586 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/34809586 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/34809586 Branch: refs/heads/master-jaxrs-2.1 Commit: 348095868d8d0e7ed363c65bfd2c05c1f691b479 Parents: 0eeeccd Author: Sergey BeryozkinAuthored: Fri Aug 12 16:34:45 2016 +0100 Committer: Sergey Beryozkin Committed: Fri Aug 12 16:34:45 2016 +0100 -- .../apache/cxf/attachment/ContentDisposition.java | 16 +--- .../apache/cxf/attachment/AttachmentUtilTest.java | 5 + 2 files changed, 18 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/cxf/blob/34809586/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java -- diff --git a/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java b/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java index 22b5daa..9ce30e9 100644 --- a/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java +++ b/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java @@ -56,9 +56,19 @@ public class ContentDisposition { String extendedFilename = null; Matcher m = CD_HEADER_PARAMS_PATTERN.matcher(tempValue); while (m.find()) { -String[] pair = m.group().trim().split("="); -String paramName = pair[0].trim(); -String paramValue = pair.length == 2 ? pair[1].trim().replace("\"", "") : ""; +String paramName = null; +String paramValue = ""; + +String groupValue = m.group().trim(); +int eqIndex = groupValue.indexOf('='); +if (eqIndex > 0) { +paramName = groupValue.substring(0, eqIndex).trim(); +if (eqIndex + 1 != groupValue.length()) { +paramValue = groupValue.substring(eqIndex + 1).trim().replace("\"", ""); +} +} else { +paramName = groupValue; +} // filename* looks like the only CD param that is human readable // and worthy of the extended encoding support. Other parameters // can be supported if needed, see the complete list below http://git-wip-us.apache.org/repos/asf/cxf/blob/34809586/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java -- diff --git a/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java b/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java index a9d3c90..d0601ff 100644 --- a/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java +++ b/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java @@ -109,4 +109,9 @@ public class AttachmentUtilTest extends Assert { "filename=\"-.zip\"")); } +@Test +public void testContentDispositionFnEquals() { +assertEquals("a=b.txt", + AttachmentUtil.getContentDispositionFileName("filename=\"a=b.txt\"")); +} }
cxf git commit: [CXF-6989] Avoding a reg-ex split when processing Content-Disposition properties
Repository: cxf Updated Branches: refs/heads/3.0.x-fixes 4bb0d4ea2 -> 877b5a7a4 [CXF-6989] Avoding a reg-ex split when processing Content-Disposition properties Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/877b5a7a Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/877b5a7a Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/877b5a7a Branch: refs/heads/3.0.x-fixes Commit: 877b5a7a460aef1beb2b46240fe8b636c0d846e2 Parents: 4bb0d4e Author: Sergey BeryozkinAuthored: Fri Aug 12 16:34:45 2016 +0100 Committer: Sergey Beryozkin Committed: Fri Aug 12 16:37:11 2016 +0100 -- .../apache/cxf/attachment/ContentDisposition.java | 16 +--- .../apache/cxf/attachment/AttachmentUtilTest.java | 5 + 2 files changed, 18 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/cxf/blob/877b5a7a/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java -- diff --git a/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java b/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java index 22b5daa..9ce30e9 100644 --- a/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java +++ b/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java @@ -56,9 +56,19 @@ public class ContentDisposition { String extendedFilename = null; Matcher m = CD_HEADER_PARAMS_PATTERN.matcher(tempValue); while (m.find()) { -String[] pair = m.group().trim().split("="); -String paramName = pair[0].trim(); -String paramValue = pair.length == 2 ? pair[1].trim().replace("\"", "") : ""; +String paramName = null; +String paramValue = ""; + +String groupValue = m.group().trim(); +int eqIndex = groupValue.indexOf('='); +if (eqIndex > 0) { +paramName = groupValue.substring(0, eqIndex).trim(); +if (eqIndex + 1 != groupValue.length()) { +paramValue = groupValue.substring(eqIndex + 1).trim().replace("\"", ""); +} +} else { +paramName = groupValue; +} // filename* looks like the only CD param that is human readable // and worthy of the extended encoding support. Other parameters // can be supported if needed, see the complete list below http://git-wip-us.apache.org/repos/asf/cxf/blob/877b5a7a/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java -- diff --git a/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java b/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java index a9d3c90..d0601ff 100644 --- a/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java +++ b/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java @@ -109,4 +109,9 @@ public class AttachmentUtilTest extends Assert { "filename=\"-.zip\"")); } +@Test +public void testContentDispositionFnEquals() { +assertEquals("a=b.txt", + AttachmentUtil.getContentDispositionFileName("filename=\"a=b.txt\"")); +} }
cxf git commit: [CXF-6989] Avoding a reg-ex split when processing Content-Disposition properties
Repository: cxf Updated Branches: refs/heads/3.1.x-fixes f63e8ad71 -> f454461fc [CXF-6989] Avoding a reg-ex split when processing Content-Disposition properties Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/f454461f Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/f454461f Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/f454461f Branch: refs/heads/3.1.x-fixes Commit: f454461fc3e449d93f296e391a8b4360f82b4321 Parents: f63e8ad Author: Sergey BeryozkinAuthored: Fri Aug 12 16:34:45 2016 +0100 Committer: Sergey Beryozkin Committed: Fri Aug 12 16:36:28 2016 +0100 -- .../apache/cxf/attachment/ContentDisposition.java | 16 +--- .../apache/cxf/attachment/AttachmentUtilTest.java | 5 + 2 files changed, 18 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/cxf/blob/f454461f/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java -- diff --git a/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java b/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java index 22b5daa..9ce30e9 100644 --- a/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java +++ b/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java @@ -56,9 +56,19 @@ public class ContentDisposition { String extendedFilename = null; Matcher m = CD_HEADER_PARAMS_PATTERN.matcher(tempValue); while (m.find()) { -String[] pair = m.group().trim().split("="); -String paramName = pair[0].trim(); -String paramValue = pair.length == 2 ? pair[1].trim().replace("\"", "") : ""; +String paramName = null; +String paramValue = ""; + +String groupValue = m.group().trim(); +int eqIndex = groupValue.indexOf('='); +if (eqIndex > 0) { +paramName = groupValue.substring(0, eqIndex).trim(); +if (eqIndex + 1 != groupValue.length()) { +paramValue = groupValue.substring(eqIndex + 1).trim().replace("\"", ""); +} +} else { +paramName = groupValue; +} // filename* looks like the only CD param that is human readable // and worthy of the extended encoding support. Other parameters // can be supported if needed, see the complete list below http://git-wip-us.apache.org/repos/asf/cxf/blob/f454461f/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java -- diff --git a/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java b/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java index a9d3c90..d0601ff 100644 --- a/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java +++ b/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java @@ -109,4 +109,9 @@ public class AttachmentUtilTest extends Assert { "filename=\"-.zip\"")); } +@Test +public void testContentDispositionFnEquals() { +assertEquals("a=b.txt", + AttachmentUtil.getContentDispositionFileName("filename=\"a=b.txt\"")); +} }
cxf git commit: [CXF-6989] Avoding a reg-ex split when processing Content-Disposition properties
Repository: cxf Updated Branches: refs/heads/master 0eeeccd94 -> 348095868 [CXF-6989] Avoding a reg-ex split when processing Content-Disposition properties Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/34809586 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/34809586 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/34809586 Branch: refs/heads/master Commit: 348095868d8d0e7ed363c65bfd2c05c1f691b479 Parents: 0eeeccd Author: Sergey BeryozkinAuthored: Fri Aug 12 16:34:45 2016 +0100 Committer: Sergey Beryozkin Committed: Fri Aug 12 16:34:45 2016 +0100 -- .../apache/cxf/attachment/ContentDisposition.java | 16 +--- .../apache/cxf/attachment/AttachmentUtilTest.java | 5 + 2 files changed, 18 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/cxf/blob/34809586/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java -- diff --git a/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java b/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java index 22b5daa..9ce30e9 100644 --- a/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java +++ b/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java @@ -56,9 +56,19 @@ public class ContentDisposition { String extendedFilename = null; Matcher m = CD_HEADER_PARAMS_PATTERN.matcher(tempValue); while (m.find()) { -String[] pair = m.group().trim().split("="); -String paramName = pair[0].trim(); -String paramValue = pair.length == 2 ? pair[1].trim().replace("\"", "") : ""; +String paramName = null; +String paramValue = ""; + +String groupValue = m.group().trim(); +int eqIndex = groupValue.indexOf('='); +if (eqIndex > 0) { +paramName = groupValue.substring(0, eqIndex).trim(); +if (eqIndex + 1 != groupValue.length()) { +paramValue = groupValue.substring(eqIndex + 1).trim().replace("\"", ""); +} +} else { +paramName = groupValue; +} // filename* looks like the only CD param that is human readable // and worthy of the extended encoding support. Other parameters // can be supported if needed, see the complete list below http://git-wip-us.apache.org/repos/asf/cxf/blob/34809586/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java -- diff --git a/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java b/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java index a9d3c90..d0601ff 100644 --- a/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java +++ b/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java @@ -109,4 +109,9 @@ public class AttachmentUtilTest extends Assert { "filename=\"-.zip\"")); } +@Test +public void testContentDispositionFnEquals() { +assertEquals("a=b.txt", + AttachmentUtil.getContentDispositionFileName("filename=\"a=b.txt\"")); +} }