zD12 / pircbotx

Automatically exported from code.google.com/p/pircbotx
0 stars 0 forks source link

Parsing error on away #172

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Another Client: /away ~
2. Another Client: /away

What is the expected output? What do you see instead?
Expected: Parsing the line -> User is no longer away. Instead the bot seems to 
be trying to set an empty away reason

What version of the product are you using? On what operating system?
pircbotx-2.0.1 on Linux 3.2.0-4-amd64 and Windows 8 Enterprise

Please provide any additional information below.
In my eyes the error is inside InputParser.java at lines 574-576:
else if (command.equals("AWAY"))
            //IRCv3 AWAY notify
            source.setAwayMessage(parsedLine.get(0));

Stacktrace:
28/38/2014@06:38:01 INFO  InputParser - :Invisi!id@host AWAY :~
28/38/2014@06:38:02 INFO  InputParser - :Invisi!id@host AWAY
28/38/2014@06:38:02 ERROR PircBotX - Exception encountered when parsing line
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.rangeCheck(ArrayList.java:635)
    at java.util.ArrayList.get(ArrayList.java:411)
    at org.pircbotx.InputParser.processCommand(InputParser.java:576)
    at org.pircbotx.InputParser.handleLine(InputParser.java:350)
    at org.pircbotx.PircBotX.startLineProcessing(PircBotX.java:275)
    at org.pircbotx.PircBotX.connect(PircBotX.java:236)
    at org.pircbotx.PircBotX.startBot(PircBotX.java:151)
    at toast.Main.main(Main.java:638)

Original issue reported on code.google.com by invisipl...@gmail.com on 28 Mar 2014 at 5:50

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
} else if (command.equals("AWAY")) { //IRCv3 AWAY notify
    if (parsedLine.isEmpty()) {
        source.setAwayMessage(null);
    } else {
        source.setAwayMessage(parsedLine.get(0));
    }
}
=> Works as expected

Original comment by invisipl...@gmail.com on 29 Mar 2014 at 9:27

GoogleCodeExporter commented 9 years ago
I don't think sending an AWAY line without a message is spec compliant, but 
since someone is doing it I fixed it in Revision 74bc25456b14 and added tests.

Original comment by Lord.Qua...@gmail.com on 16 Apr 2014 at 3:54