You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/07/29 19:49:14 UTC
[commons-cli] branch master updated: Fix NPE in
DefaultParser.isLongOption(String) seen in the wild.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-cli.git
The following commit(s) were added to refs/heads/master by this push:
new 81cf673 Fix NPE in DefaultParser.isLongOption(String) seen in the wild.
81cf673 is described below
commit 81cf67387da844052aaa4c6feb4c8b290308e0eb
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Jul 29 15:49:10 2021 -0400
Fix NPE in DefaultParser.isLongOption(String) seen in the wild.
---
src/changes/changes.xml | 6 ++++++
src/main/java/org/apache/commons/cli/DefaultParser.java | 4 ++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index d58001e..54bf307 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -23,9 +23,14 @@
<body>
<release version="1.5" date="tba" description="tba">
+ <!-- FIX -->
+ <action type="update" dev="ggregory" due-to="Gary Gregory">
+ Fix NPE in DefaultParser.isLongOption(String).
+ </action>
<action type="update" dev="britter" due-to="Krishna Mohan Rao Kandunoori" issue="CLI-279">
@param or @return lines should end with a period in CommandLine.java
</action>
+ <!-- ADD -->
<action type="add" dev="chtompki" due-to="Rubin Simons" issue="CLI-217">
Accommodate toggling partial matching in DefaultParser.
</action>
@@ -41,6 +46,7 @@
<action type="add" dev="ggregory" due-to="Alex Nordlund" issue="CLI-282">
TypeHandler should throw ParseException for an unsupported class.
</action>
+ <!-- UPDATE -->
<action type="update" dev="ggregory" issue="CLI-294">
Update Java from version 5 to 7.
</action>
diff --git a/src/main/java/org/apache/commons/cli/DefaultParser.java b/src/main/java/org/apache/commons/cli/DefaultParser.java
index c2a97e2..64849dc 100644
--- a/src/main/java/org/apache/commons/cli/DefaultParser.java
+++ b/src/main/java/org/apache/commons/cli/DefaultParser.java
@@ -347,7 +347,7 @@ public class DefaultParser implements CommandLineParser
private boolean isShortOption(final String token)
{
// short options (-S, -SV, -S=V, -SV1=V2, -S1S2)
- if (!token.startsWith("-") || token.length() == 1)
+ if (token == null || !token.startsWith("-") || token.length() == 1)
{
return false;
}
@@ -370,7 +370,7 @@ public class DefaultParser implements CommandLineParser
*/
private boolean isLongOption(final String token)
{
- if (!token.startsWith("-") || token.length() == 1)
+ if (token == null || !token.startsWith("-") || token.length() == 1)
{
return false;
}