Author: sshafroi
Date: 2008-11-25 08:59:41 +0100 (Tue, 25 Nov 2008)
New Revision: 6979
Modified:
branches/2.18/result-spi/src/main/java/no/sesat/search/result/StringChopper.java
Log:
Fix nullpointer exception, and add handeling of incomplete tags at end of
string. If you have a string like "<fisk>and<kra" it will end up like
"<fisk>and</fisk>" and "<kra" is removed.
Modified:
branches/2.18/result-spi/src/main/java/no/sesat/search/result/StringChopper.java
===================================================================
---
branches/2.18/result-spi/src/main/java/no/sesat/search/result/StringChopper.java
2008-11-24 22:35:43 UTC (rev 6978)
+++
branches/2.18/result-spi/src/main/java/no/sesat/search/result/StringChopper.java
2008-11-25 07:59:41 UTC (rev 6979)
@@ -175,6 +175,15 @@
res.append(c);
}
+ // remove unclosed tag
+ if (state == State.TAG || state == State.STARTTAG || state ==
State.ENDTAG) {
+ int pos = res.lastIndexOf("<");
+ res.setLength(pos);
+ if (state == State.STARTTAG) {
+ stack.pop();
+ }
+ }
+
// append dots
if (i < s.length - 1) {
if (!chop) {
@@ -197,11 +206,10 @@
// close all other open tags
while (!stack.isEmpty()) {
int j = stack.pop();
- char c = s[j];
res.append("</");
- while (s.length > j && c != '>') {
- res.append(c);
- c = s[++j];
+ while (s.length > j && s[j] != '>') {
+ res.append(s[j]);
+ j++;
}
res.append('>');
}
_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits