diff options
Diffstat (limited to 'test/java')
| -rw-r--r-- | test/java/net/yacy/search/snippet/TextSnippetTest.java | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/test/java/net/yacy/search/snippet/TextSnippetTest.java b/test/java/net/yacy/search/snippet/TextSnippetTest.java index 2d12c5d24..c89cee47e 100644 --- a/test/java/net/yacy/search/snippet/TextSnippetTest.java +++ b/test/java/net/yacy/search/snippet/TextSnippetTest.java @@ -158,8 +158,8 @@ public class TextSnippetTest { * checking poper encoding of remaining html in raw snippet line.
*/
@Test
- public void testDescriptionline() throws MalformedURLException {
- String rawtestline = "Über großer test case </span> <pre> <hr><hr /></pre>"; // test line with html, risk of snippet format issue
+ public void testDescriptionline() throws MalformedURLException { + String rawtestline = "Über großer test case </span> <pre> <hr><hr /></pre>"; // test line with html, risk of snippet format issue DigestURL url = new DigestURL("http://localhost/page.html");
QueryGoal qg = new QueryGoal("test");
@@ -196,9 +196,27 @@ public class TextSnippetTest { TextSnippet.ResultClass.SOURCE_METADATA, "");
sniptxt = ts.descriptionline(qg);
System.out.println("testDescriptionline: (with numbers) snippet="+sniptxt);
- assertTrue ("number (.) broken up",sniptxt.contains("1.83"));
- assertTrue ("number (,) broken up",sniptxt.contains("3,14"));
- }
+ assertTrue ("number (.) broken up",sniptxt.contains("1.83")); + assertTrue ("number (,) broken up",sniptxt.contains("3,14")); + } + + @Test + public void testDescriptionlineRemovesSuspiciousJavaScriptBraceBlock() throws MalformedURLException { + final String rawtestline = "Springe zur Suche Springe zum Fußbereich { this.mobileMainNavHeight = el.getBoundingClientRect().height; }); } }"; + final DigestURL url = new DigestURL("http://localhost/page.html"); + final QueryGoal qg = new QueryGoal("Suche"); + + final TextSnippet ts = new TextSnippet( + url, + rawtestline, + true, + TextSnippet.ResultClass.SOURCE_METADATA, ""); + + final String sniptxt = ts.descriptionline(qg); + assertTrue(sniptxt.contains("Springe zur Suche")); + assertFalse(sniptxt.contains("getBoundingClientRect")); + assertFalse(sniptxt.contains("mobileMainNavHeight")); + } /**
* Run text snippet extraction from a given plain text file.
|
