Package com.adobe.epubcheck.messages

Examples of com.adobe.epubcheck.messages.MessageLocation


      String extension = ResourceUtil.getExtension(epubFile.getName());
      checkExtension(extension);

      if (!epubFile.exists())
      {
        report.message(MessageId.PKG_018, new MessageLocation(epubFile.getName(), -1, -1));
        return 2;
      }

      epubIn = new FileInputStream(epubFile);
      checkEpubHeader(epubIn);
      zip = new ZipFile(epubFile);

      /***Here are called custom checks (CTC Package)**/
      CheckManager c = new CheckManager(zip, report);
      c.checkPackage();

      OCFPackage ocf = new OCFZipPackage(zip);
      OCFChecker checker = new OCFChecker(ocf, report, null);
      checker.runChecks();

      CheckMultiplePaginationSchemes();

    }
    catch (IOException e)
    {
      report.message(MessageId.PKG_008, new MessageLocation(epubFile.getName(), 0, 0, ""), e.getMessage());
    }
    finally
    {
      try
      {
View Full Code Here


  public void CheckMultiplePaginationSchemes()
  {
    Set<MessageId> reported = MasterReport.localReportedMessageIds;
    if (reported.contains(MessageId.NAV_002) && reported.contains(MessageId.HTM_050))
    {
      report.message(MessageId.NAV_003, new MessageLocation(epubFile.getName(), -1, -1));
    }
    if (reported.contains(MessageId.NCX_005) && reported.contains(MessageId.OPF_062))
    {
      report.message(MessageId.NCX_006, new MessageLocation(epubFile.getName(), -1, -1));
    }
  }
View Full Code Here

    {
      if (!extension.equals("epub"))
      {
        if (extension.matches("[Ee][Pp][Uu][Bb]"))
        {
          report.message(MessageId.PKG_016, new MessageLocation(epubFile.getName(), -1, -1));
        }
        else
        {
          report.message(MessageId.PKG_017, new MessageLocation(epubFile.getName(), -1, -1, extension));
        }
      }
    }
  }
View Full Code Here

      }
    }

    if (readCount != header.length)
    {
      report.message(MessageId.PKG_003, new MessageLocation(epubFile.getName(), 0, 0, ""));
    }
    else
    {
      int fnsize = getIntFromBytes(header, 26);
      int extsize = getIntFromBytes(header, 28);

      if (header[0] != 'P' && header[1] != 'K')
      {
        report.message(MessageId.PKG_004, new MessageLocation(epubFile.getName(), 0, 0));
      }
      else if (fnsize != 8)
      {
        report.message(MessageId.PKG_006, new MessageLocation(epubFile.getName(), 0, 0));
      }
      else if (extsize != 0)
      {
        report.message(MessageId.PKG_005, new MessageLocation(epubFile.getName(), 0, 0), extsize);
      }
      else if (!CheckUtil.checkString(header, 30, "mimetype"))
      {
        report.message(MessageId.PKG_006, new MessageLocation(epubFile.getName(), 0, 0));
      }
      else if (!CheckUtil.checkString(header, 38,
          "application/epub+zip"))
      {
        report.message(MessageId.PKG_007, new MessageLocation(epubFile.getName(), 0, 0));
      }
    }
  }
View Full Code Here

        ScriptTagHandler sh = new ScriptTagHandler(this.report);
        String fileToParse = epack.getManifestItemFileName(mi);
        ZipEntry entry = this.zip.getEntry(fileToParse);
        if (entry == null)
        {
          report.message(MessageId.RSC_001, new MessageLocation(this.epack.getFileName(), -1, -1), fileToParse);
          continue;
        }
        sh.setFileName(fileToParse);
        sh.setVersion(epack.getVersion());
        parser.parseDoc(fileToParse, sh);
        if (sh.getScriptElementCount() > 0 || sh.getInlineScriptCount() > 0)
        {
          if (sh.getInlineScriptCount() > 0)
          {
            report.info(fileToParse, FeatureEnum.SCRIPT, "inline");
          }
          if (sh.getScriptElementCount() > 0)
          {
            report.info(fileToParse, FeatureEnum.SCRIPT, "tag");
          }
          if (epack.getVersion() != EPUBVersion.VERSION_2)
          {
            report.message(MessageId.SCP_010, new MessageLocation(fileToParse, -1, -1));
            if (mi.getProperties() == null || !mi.getProperties().contains("scripted"))
            {
              report.message(MessageId.SCP_005, new MessageLocation(fileToParse, -1, -1));
            }
          }
        }
      }
View Full Code Here

    {
      String fileToParse = epack.getManifestItemFileName(mi);
      ZipEntry entry = this.zip.getEntry(fileToParse);
      if (entry == null)
      {
        report.message(MessageId.RSC_001, new MessageLocation(fileToParse, -1, -1), fileToParse);
        return;
      }
      report.info(fileToParse, FeatureEnum.SCRIPT, "javascript");
      report.info(fileToParse, FeatureEnum.HAS_SCRIPTS, "");

      if (epack.getVersion() == EPUBVersion.VERSION_2)
      {
        report.message(MessageId.SCP_004, new MessageLocation(fileToParse, -1, -1));
      }
      else
      {
        report.message(MessageId.SCP_010, new MessageLocation(fileToParse, -1, -1));
      }

      try
      {
        is = zip.getInputStream(entry);
        reader = new BufferedReader(new InputStreamReader(is));
        int lineNumber = 0;
        while (reader.ready())
        {
          String line = reader.readLine();
          ++lineNumber;
          CheckForInner(fileToParse, lineNumber, line);
        }
        reader.close();
        is.close();
      }
      catch (FileNotFoundException ex)
      {
        report.message(MessageId.RSC_001, new MessageLocation(fileToParse, -1, -1), fileToParse);
      }
      catch (IOException ex)
      {
        report.message(MessageId.PKG_008, new MessageLocation(fileToParse, -1, -1), fileToParse);
      }
      finally
      {
        if (reader != null)
        {
View Full Code Here

  {
    String lower = script.toLowerCase();
    int column = lower.indexOf("innerhtml");
    if (column >= 0)
    {
      report.message(MessageId.SCP_007, new MessageLocation(fileName, line, column, trimContext(script, column)));
    }

    column = lower.indexOf("innertext");
    if (column >= 0)
    {
      report.message(MessageId.SCP_008, new MessageLocation(fileName, line, column, trimContext(script, column)));
    }

    // the exact pattern is very complex and it slows down all script checking.
    //  what we can do here is use a blunt check (for the word "eval").  if it is not found, keep moving.
    //  If it is found, look closely using the exact pattern to see if the line truly matches the exact eval() function and report that.
    Matcher m = null;
    if (script.contains("eval"))
    {
      m = ScriptTagHandler.evalPattern.matcher(script);
      if (m.find())
      {
        report.message(MessageId.SCP_001, new MessageLocation(fileName, line, m.start(0), trimContext(script, m.start())));
      }
    }

    m = ScriptTagHandler.localStoragePattern.matcher(script);
    if (m.find())
    {
      report.message(MessageId.SCP_003, new MessageLocation(fileName, line, m.start(0), trimContext(script, m.start())));
    }
    m = ScriptTagHandler.sessionStoragePattern.matcher(script);
    if (m.find())
    {
      report.message(MessageId.SCP_003, new MessageLocation(fileName, line, m.start(0), trimContext(script, m.start())));
    }
    m = ScriptTagHandler.xmlHttpRequestPattern.matcher(script);
    if (m.find())
    {
      report.message(MessageId.SCP_002, new MessageLocation(fileName, line, m.start(0), trimContext(script, m.start())));
    }
    m = ScriptTagHandler.microsoftXmlHttpRequestPattern.matcher(script);
    if (m.find())
    {
      report.message(MessageId.SCP_002, new MessageLocation(fileName, line, m.start(0), trimContext(script, m.start())));
    }
  }
View Full Code Here

    String version = parser.getXMLVersion();

    //I don't think it is possible for this to be null.  A null version would cause a SAX parser error.
    if (version == null)
    {
      parser.getReport().message(MessageId.HTM_002, new MessageLocation(parser.getResourceName(),
          parser.getLineNumber(), parser.getColumnNumber()));
    }
    else if (!"1.0".equals(version))
    {
      parser.getReport().message(MessageId.HTM_001, new MessageLocation(parser.getResourceName(),
          parser.getLineNumber(), parser.getColumnNumber()), version);
    }
  }
View Full Code Here

  public void runChecks()
  {
    if (!ocf.hasEntry(path))
    {
      report.message(MessageId.PKG_020, new MessageLocation(this.ocf.getName(), 0, 0), path);
      return;
    }
    validate();

    if (!opfHandler.checkUniqueIdentExists())
    {
      report.message(MessageId.OPF_030, new MessageLocation(path, -1, -1), opfHandler.getIdentId());
    } else {
      ocf.setUniqueIdentifier(opfHandler.getUid());
    }

    int itemCount = opfHandler.getItemCount();
    report.info(null, FeatureEnum.ITEMS_COUNT, Integer.toString(itemCount));
    for (int i = 0; i < itemCount; i++)
    {
      OPFItem item = opfHandler.getItem(i);
      try
      {
        xrefChecker.registerResource(item.getPath(),
            item.getMimeType(), item.isInSpine(),
            new FallbackChecker().checkItemFallbacks(item, opfHandler, true),
            new FallbackChecker().checkImageFallbacks(item, opfHandler));
      }
      catch (IllegalArgumentException e)
      {
        report.message(MessageId.RSC_005,
            new MessageLocation(path, item.getLineNumber(), item.getColumnNumber()),
            e.getMessage());
      }

      report.info(item.getPath(), FeatureEnum.DECLARED_MIMETYPE, item.getMimeType());
    }
View Full Code Here

      String itemPath = PathUtil.removeAnchor(ref.getHref());
      OPFItem item = opfHandler.getItemByPath(itemPath);
      if (item == null)
      {
        report.message(MessageId.OPF_031,
            new MessageLocation(path, ref.getLineNumber(), ref.getColumnNumber()),
            ref.getHref());
      }
      else
      {
        if (!isBlessedItemType(item.mimeType, version) &&
            !isDeprecatedBlessedItemType(item.mimeType))
        {
          report.message(MessageId.OPF_032,
              new MessageLocation(path, ref.getLineNumber(), ref.getColumnNumber()),
              ref.getHref());
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.adobe.epubcheck.messages.MessageLocation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.