Revision: 7365
          
http://languagetool.svn.sourceforge.net/languagetool/?rev=7365&view=rev
Author:   milek_pl
Date:     2012-06-16 11:15:05 +0000 (Sat, 16 Jun 2012)
Log Message:
-----------
fix ArrayOutOfBounds when a non-existent rule is enabled for STDIN mode

Modified Paths:
--------------
    trunk/JLanguageTool/src/java/org/languagetool/Main.java
    trunk/JLanguageTool/src/test/org/languagetool/MainTest.java

Modified: trunk/JLanguageTool/src/java/org/languagetool/Main.java
===================================================================
--- trunk/JLanguageTool/src/java/org/languagetool/Main.java     2012-06-16 
10:32:00 UTC (rev 7364)
+++ trunk/JLanguageTool/src/java/org/languagetool/Main.java     2012-06-16 
11:15:05 UTC (rev 7365)
@@ -218,7 +218,7 @@
     int tmpLineOffset = 0;
     final List<String> unknownWords = new ArrayList<String>();
     StringBuilder sb = new StringBuilder();
-    for (int ruleIndex = 0; ruleIndex < runCount; ruleIndex++) {
+    for (int ruleIndex = 0; !rules.isEmpty() && ruleIndex < runCount; 
ruleIndex++) {
       currentRule = rules.get(ruleIndex);
       int matches = 0;
       long sentences = 0;

Modified: trunk/JLanguageTool/src/test/org/languagetool/MainTest.java
===================================================================
--- trunk/JLanguageTool/src/test/org/languagetool/MainTest.java 2012-06-16 
10:32:00 UTC (rev 7364)
+++ trunk/JLanguageTool/src/test/org/languagetool/MainTest.java 2012-06-16 
11:15:05 UTC (rev 7365)
@@ -236,7 +236,20 @@
     assertTrue(output.indexOf("Expected text language: English") == 0);
     assertTrue(output.contains("Rule ID: EN_A_VS_AN"));
   }
+
+  public void testEnglishFileFakeRuleEnabled() throws Exception {
+    final String test = "Zwuasdac?";
+    final byte[] b = test.getBytes();
+    System.setIn(new ByteArrayInputStream(b));
+    String[] args = new String[] {"-l", "en", "-e", "FOO_BAR_BLABLA", "-"};
+
+    Main.main(args);
+    String output = new String(this.out.toByteArray());
+    assertTrue(output.indexOf("Expected text language: English") == 0);
+  }
+
   
+  
   public void testEnglishFileAPI() throws Exception {
     final URL url = this.getClass().getResource(ENGLISH_TEST_FILE);
     final URI uri = new URI (url.toString());

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Languagetool-cvs mailing list
Languagetool-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/languagetool-cvs

Reply via email to