You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Benedikt Ritter <br...@apache.org> on 2013/10/26 10:53:52 UTC

Re: svn commit: r1535911 - in /commons/proper/lang/trunk/src: changes/changes.xml main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java

Hi Hen,


2013/10/26 <ba...@apache.org>

> Author: bayard
> Date: Sat Oct 26 02:14:35 2013
> New Revision: 1535911
>
> URL: http://svn.apache.org/r1535911
> Log:
> Applying github pull request https://github.com/apache/commons-lang/pull/5,
> linked as LANG-928, fixing a bug in OctalEscaper trying to parse octal
> numbers longer than 3 digits
>
> Modified:
>     commons/proper/lang/trunk/src/changes/changes.xml
>
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java
>
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
>
> Modified: commons/proper/lang/trunk/src/changes/changes.xml
> URL:
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/changes/changes.xml?rev=1535911&r1=1535910&r2=1535911&view=diff
>
> ==============================================================================
> --- commons/proper/lang/trunk/src/changes/changes.xml (original)
> +++ commons/proper/lang/trunk/src/changes/changes.xml Sat Oct 26 02:14:35
> 2013
> @@ -22,6 +22,7 @@
>    <body>
>
>    <release version="3.2" date="TBA" description="Next release">
> +    <action issue="LANG-928" type="fix">OctalUnescaper has bugs when
> parsing octals starting with a zero</action>
>

Although you have rewritten the code afterwards, it seems fair to give the
contributor the kudos, WDYT?


>      <action issue="LANG-905" type="fix">EqualsBuilder returns true when
> comparing arrays, even when the elements are different</action>
>      <action issue="LANG-774" type="add" due-to="Erhan Bagdemir">Added
> isStarted, isSuspended and isStopped to StopWatch</action>
>      <action issue="LANG-917" type="fix" due-to="Arne Burmeister">Fixed
> exception when combining custom and choice format in
> ExtendedMessageFormat</action>
>
> Modified:
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java?rev=1535911&r1=1535910&r2=1535911&view=diff
>
> ==============================================================================
> ---
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java
> (original)
> +++
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java
> Sat Oct 26 02:14:35 2013
> @@ -50,6 +50,10 @@ public class OctalUnescaper extends Char
>                      end--; // rollback
>                      break;
>                  }
> +                // only 3 characters applicable for Octal
> +                if (end - start >= 3) {
> +                    break;
> +                }
>              }
>
>              out.write( Integer.parseInt(input.subSequence(start,
> end).toString(), 8) );
>
> Modified:
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java?rev=1535911&r1=1535910&r2=1535911&view=diff
>
> ==============================================================================
> ---
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
> (original)
> +++
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
> Sat Oct 26 02:14:35 2013
> @@ -44,15 +44,44 @@ public class OctalUnescaperTest {
>
>          input = "\\378 and";
>          result = oue.translate(input);
> -        assertEquals("Failed to unescape octal characters via the between
> method", "\378 and", result);
> +        assertEquals("Failed to unescape octal characters via the between
> method", "\37" + "8 and", result);
>
>          input = "\\378";
>          result = oue.translate(input);
> -        assertEquals("Failed to unescape octal characters via the between
> method", "\378", result);
> +        assertEquals("Failed to unescape octal characters via the between
> method", "\37" + "8", result);
>
>          input = "\\1";
>          result = oue.translate(input);
>          assertEquals("Failed to unescape octal characters via the between
> method", "\1", result);
> +
> +        input = "\\036";
> +        result = oue.translate(input);
> +        assertEquals("Failed to unescape octal characters via the between
> method", "\036", result);
> +
> +        input = "\\0365";
> +        result = oue.translate(input);
> +        assertEquals("Failed to unescape octal characters via the between
> method", "\036" + "5", result);
> +
> +        input = "\\003";
> +        result = oue.translate(input);
> +        assertEquals("Failed to unescape octal characters via the between
> method", "\003", result);
> +
> +        input = "\\0003";
> +        result = oue.translate(input);
> +        assertEquals("Failed to unescape octal characters via the between
> method", "\000" + "3", result);
> +    }
> +
> +    @Test
> +    public void testOutOfRange() {
> +        final OctalUnescaper oue = new OctalUnescaper();
> +
> +        String input = "\\999";
> +        try {
> +            String result = oue.translate(input);
> +            fail("NumberFormatException was expected for input: " +
> input);
> +        } catch(NumberFormatException nfe) {
> +            // expected
> +        }
>      }
>
>  }
>
>
>


-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter

Re: svn commit: r1535911 - in /commons/proper/lang/trunk/src: changes/changes.xml main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java

Posted by Benedikt Ritter <be...@gmail.com>.
Agreed, fanxu123 would be a strange name for due-to :-)

2013/10/26 Henri Yandell <fl...@gmail.com>

> Their name isn't listed on GitHub.
>
>
> On Sat, Oct 26, 2013 at 1:53 AM, Benedikt Ritter <br...@apache.org>
> wrote:
>
> > Hi Hen,
> >
> >
> > 2013/10/26 <ba...@apache.org>
> >
> > > Author: bayard
> > > Date: Sat Oct 26 02:14:35 2013
> > > New Revision: 1535911
> > >
> > > URL: http://svn.apache.org/r1535911
> > > Log:
> > > Applying github pull request
> > https://github.com/apache/commons-lang/pull/5,
> > > linked as LANG-928, fixing a bug in OctalEscaper trying to parse octal
> > > numbers longer than 3 digits
> > >
> > > Modified:
> > >     commons/proper/lang/trunk/src/changes/changes.xml
> > >
> > >
> >
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java
> > >
> > >
> >
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
> > >
> > > Modified: commons/proper/lang/trunk/src/changes/changes.xml
> > > URL:
> > >
> >
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/changes/changes.xml?rev=1535911&r1=1535910&r2=1535911&view=diff
> > >
> > >
> >
> ==============================================================================
> > > --- commons/proper/lang/trunk/src/changes/changes.xml (original)
> > > +++ commons/proper/lang/trunk/src/changes/changes.xml Sat Oct 26
> 02:14:35
> > > 2013
> > > @@ -22,6 +22,7 @@
> > >    <body>
> > >
> > >    <release version="3.2" date="TBA" description="Next release">
> > > +    <action issue="LANG-928" type="fix">OctalUnescaper has bugs when
> > > parsing octals starting with a zero</action>
> > >
> >
> > Although you have rewritten the code afterwards, it seems fair to give
> the
> > contributor the kudos, WDYT?
> >
> >
> > >      <action issue="LANG-905" type="fix">EqualsBuilder returns true
> when
> > > comparing arrays, even when the elements are different</action>
> > >      <action issue="LANG-774" type="add" due-to="Erhan Bagdemir">Added
> > > isStarted, isSuspended and isStopped to StopWatch</action>
> > >      <action issue="LANG-917" type="fix" due-to="Arne Burmeister">Fixed
> > > exception when combining custom and choice format in
> > > ExtendedMessageFormat</action>
> > >
> > > Modified:
> > >
> >
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java
> > > URL:
> > >
> >
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java?rev=1535911&r1=1535910&r2=1535911&view=diff
> > >
> > >
> >
> ==============================================================================
> > > ---
> > >
> >
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java
> > > (original)
> > > +++
> > >
> >
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java
> > > Sat Oct 26 02:14:35 2013
> > > @@ -50,6 +50,10 @@ public class OctalUnescaper extends Char
> > >                      end--; // rollback
> > >                      break;
> > >                  }
> > > +                // only 3 characters applicable for Octal
> > > +                if (end - start >= 3) {
> > > +                    break;
> > > +                }
> > >              }
> > >
> > >              out.write( Integer.parseInt(input.subSequence(start,
> > > end).toString(), 8) );
> > >
> > > Modified:
> > >
> >
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
> > > URL:
> > >
> >
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java?rev=1535911&r1=1535910&r2=1535911&view=diff
> > >
> > >
> >
> ==============================================================================
> > > ---
> > >
> >
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
> > > (original)
> > > +++
> > >
> >
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
> > > Sat Oct 26 02:14:35 2013
> > > @@ -44,15 +44,44 @@ public class OctalUnescaperTest {
> > >
> > >          input = "\\378 and";
> > >          result = oue.translate(input);
> > > -        assertEquals("Failed to unescape octal characters via the
> > between
> > > method", "\378 and", result);
> > > +        assertEquals("Failed to unescape octal characters via the
> > between
> > > method", "\37" + "8 and", result);
> > >
> > >          input = "\\378";
> > >          result = oue.translate(input);
> > > -        assertEquals("Failed to unescape octal characters via the
> > between
> > > method", "\378", result);
> > > +        assertEquals("Failed to unescape octal characters via the
> > between
> > > method", "\37" + "8", result);
> > >
> > >          input = "\\1";
> > >          result = oue.translate(input);
> > >          assertEquals("Failed to unescape octal characters via the
> > between
> > > method", "\1", result);
> > > +
> > > +        input = "\\036";
> > > +        result = oue.translate(input);
> > > +        assertEquals("Failed to unescape octal characters via the
> > between
> > > method", "\036", result);
> > > +
> > > +        input = "\\0365";
> > > +        result = oue.translate(input);
> > > +        assertEquals("Failed to unescape octal characters via the
> > between
> > > method", "\036" + "5", result);
> > > +
> > > +        input = "\\003";
> > > +        result = oue.translate(input);
> > > +        assertEquals("Failed to unescape octal characters via the
> > between
> > > method", "\003", result);
> > > +
> > > +        input = "\\0003";
> > > +        result = oue.translate(input);
> > > +        assertEquals("Failed to unescape octal characters via the
> > between
> > > method", "\000" + "3", result);
> > > +    }
> > > +
> > > +    @Test
> > > +    public void testOutOfRange() {
> > > +        final OctalUnescaper oue = new OctalUnescaper();
> > > +
> > > +        String input = "\\999";
> > > +        try {
> > > +            String result = oue.translate(input);
> > > +            fail("NumberFormatException was expected for input: " +
> > > input);
> > > +        } catch(NumberFormatException nfe) {
> > > +            // expected
> > > +        }
> > >      }
> > >
> > >  }
> > >
> > >
> > >
> >
> >
> > --
> > http://people.apache.org/~britter/
> > http://www.systemoutprintln.de/
> > http://twitter.com/BenediktRitter
> > http://github.com/britter
> >
>

Re: svn commit: r1535911 - in /commons/proper/lang/trunk/src: changes/changes.xml main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java

Posted by Henri Yandell <fl...@gmail.com>.
Their name isn't listed on GitHub.


On Sat, Oct 26, 2013 at 1:53 AM, Benedikt Ritter <br...@apache.org> wrote:

> Hi Hen,
>
>
> 2013/10/26 <ba...@apache.org>
>
> > Author: bayard
> > Date: Sat Oct 26 02:14:35 2013
> > New Revision: 1535911
> >
> > URL: http://svn.apache.org/r1535911
> > Log:
> > Applying github pull request
> https://github.com/apache/commons-lang/pull/5,
> > linked as LANG-928, fixing a bug in OctalEscaper trying to parse octal
> > numbers longer than 3 digits
> >
> > Modified:
> >     commons/proper/lang/trunk/src/changes/changes.xml
> >
> >
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java
> >
> >
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
> >
> > Modified: commons/proper/lang/trunk/src/changes/changes.xml
> > URL:
> >
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/changes/changes.xml?rev=1535911&r1=1535910&r2=1535911&view=diff
> >
> >
> ==============================================================================
> > --- commons/proper/lang/trunk/src/changes/changes.xml (original)
> > +++ commons/proper/lang/trunk/src/changes/changes.xml Sat Oct 26 02:14:35
> > 2013
> > @@ -22,6 +22,7 @@
> >    <body>
> >
> >    <release version="3.2" date="TBA" description="Next release">
> > +    <action issue="LANG-928" type="fix">OctalUnescaper has bugs when
> > parsing octals starting with a zero</action>
> >
>
> Although you have rewritten the code afterwards, it seems fair to give the
> contributor the kudos, WDYT?
>
>
> >      <action issue="LANG-905" type="fix">EqualsBuilder returns true when
> > comparing arrays, even when the elements are different</action>
> >      <action issue="LANG-774" type="add" due-to="Erhan Bagdemir">Added
> > isStarted, isSuspended and isStopped to StopWatch</action>
> >      <action issue="LANG-917" type="fix" due-to="Arne Burmeister">Fixed
> > exception when combining custom and choice format in
> > ExtendedMessageFormat</action>
> >
> > Modified:
> >
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java
> > URL:
> >
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java?rev=1535911&r1=1535910&r2=1535911&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java
> > (original)
> > +++
> >
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java
> > Sat Oct 26 02:14:35 2013
> > @@ -50,6 +50,10 @@ public class OctalUnescaper extends Char
> >                      end--; // rollback
> >                      break;
> >                  }
> > +                // only 3 characters applicable for Octal
> > +                if (end - start >= 3) {
> > +                    break;
> > +                }
> >              }
> >
> >              out.write( Integer.parseInt(input.subSequence(start,
> > end).toString(), 8) );
> >
> > Modified:
> >
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
> > URL:
> >
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java?rev=1535911&r1=1535910&r2=1535911&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
> > (original)
> > +++
> >
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
> > Sat Oct 26 02:14:35 2013
> > @@ -44,15 +44,44 @@ public class OctalUnescaperTest {
> >
> >          input = "\\378 and";
> >          result = oue.translate(input);
> > -        assertEquals("Failed to unescape octal characters via the
> between
> > method", "\378 and", result);
> > +        assertEquals("Failed to unescape octal characters via the
> between
> > method", "\37" + "8 and", result);
> >
> >          input = "\\378";
> >          result = oue.translate(input);
> > -        assertEquals("Failed to unescape octal characters via the
> between
> > method", "\378", result);
> > +        assertEquals("Failed to unescape octal characters via the
> between
> > method", "\37" + "8", result);
> >
> >          input = "\\1";
> >          result = oue.translate(input);
> >          assertEquals("Failed to unescape octal characters via the
> between
> > method", "\1", result);
> > +
> > +        input = "\\036";
> > +        result = oue.translate(input);
> > +        assertEquals("Failed to unescape octal characters via the
> between
> > method", "\036", result);
> > +
> > +        input = "\\0365";
> > +        result = oue.translate(input);
> > +        assertEquals("Failed to unescape octal characters via the
> between
> > method", "\036" + "5", result);
> > +
> > +        input = "\\003";
> > +        result = oue.translate(input);
> > +        assertEquals("Failed to unescape octal characters via the
> between
> > method", "\003", result);
> > +
> > +        input = "\\0003";
> > +        result = oue.translate(input);
> > +        assertEquals("Failed to unescape octal characters via the
> between
> > method", "\000" + "3", result);
> > +    }
> > +
> > +    @Test
> > +    public void testOutOfRange() {
> > +        final OctalUnescaper oue = new OctalUnescaper();
> > +
> > +        String input = "\\999";
> > +        try {
> > +            String result = oue.translate(input);
> > +            fail("NumberFormatException was expected for input: " +
> > input);
> > +        } catch(NumberFormatException nfe) {
> > +            // expected
> > +        }
> >      }
> >
> >  }
> >
> >
> >
>
>
> --
> http://people.apache.org/~britter/
> http://www.systemoutprintln.de/
> http://twitter.com/BenediktRitter
> http://github.com/britter
>