Uploaded image for project: 'Tika'
  1. Tika
  2. TIKA-394

Missing spaces on html parsing

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 0.6
    • 0.8
    • parser
    • Tomcat 6, Windows XP (russian locale)

    Description

      On parsing such html code:

      text<p>more<br>yet<select><option>city1<option>city2</select>

      resulting text is:

      textmore
      yetcity1city2

      But must be:

      text
      more
      yet city1 city2

      Code sample:

      import java.io.*;
      import org.apache.tika.metadata.*;
      import org.apache.tika.parser.*;

      public class test {

      public static void main(String[] args) throws Exception {
      Metadata metadata = new Metadata();
      metadata.set(Metadata.CONTENT_TYPE, "text/html");
      String content = "text<p>more<br>yet<select><option>city1<option>city2</select>";

      InputStream in = new ByteArrayInputStream(content.getBytes("UTF-8"));
      AutoDetectParser parser = new AutoDetectParser();
      Reader reader = new ParsingReader(parser, in, metadata, new ParseContext());
      char[] buf = new char[10000];
      int len;
      StringBuffer text = new StringBuffer();
      while((len = reader.read(buf)) > 0)

      { text.append(buf, 0, len); }

      System.out.print(text);
      }
      }

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            kkrugler Kenneth William Krugler
            edhel Andrey Barhatov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment