r108996 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108995‎ | r108996 | r108997 >
Date:19:09, 15 January 2012
Author:oren
Status:deferred
Tags:
Comment:
error handling for non numeric definition
Modified paths:
  • /trunk/lucene-search-2/src/org/wikimedia/lsearch/search/NamespaceFilter.java (modified) (history)

Diff [purge]

Index: trunk/lucene-search-2/src/org/wikimedia/lsearch/search/NamespaceFilter.java
@@ -56,13 +56,26 @@
5757 init();
5858 included.set(namespace);
5959 }
60 - /** filter number of namespaces separated by comma, e.g. 0,2,10 */
 60+ /**
 61+ *
 62+ * filter number of namespaces separated by comma, e.g. 0,2,10 */
6163 public NamespaceFilter(String namespaces) {
6264 init();
6365 if (namespaces != null && !namespaces.equals("")) {
6466 String[] bits = namespaces.split(",");
6567 for (int i = 0; i < bits.length; i++) {
 68+ try{
6669 included.set(Integer.parseInt(bits[i].trim()));
 70+ }
 71+ catch (NumberFormatException e)
 72+ {
 73+ if(bits[i].trim().startsWith("NS"))
 74+ {
 75+ System.err.println("bad input found by NamespaceFilter "+ bits[i]);
 76+ included.set(Integer.parseInt("0"));
 77+ }
 78+
 79+ }
6780 }
6881 }
6982 }

Status & tagging log