Browse Source

Merge pull request #282 in CORE/base-third from ~HARRISON/base-third:feature/10.0 to feature/10.0

* commit '2581cb327ad8b04967c50f84c7f7b1cd8c20ca99':
  CHART-10607 linux下缺失了系统供应商信息的文件会导致栈溢出
  REPORT-20433 html片段导出table表格被压缩
  REPORT-20372 CVE-2017-5644 fix
  CUSTBUG-43276 pdf导出后。html显示的图片被裁切了
  DEC-8889 jackson高危漏洞
  KERNER-724 j2v8升级
  DEC-8173 脏数据导致quartz启动失败
  DEC-7569 定时调度模块启动异常
  无JIRA任务 打包失败,job未初始化
  DEC-7376 定时调度任务表中存在脏数据的时候,不能影响整个scheduler
  DEC-7376 定时调度任务表中存在脏数据的时候,不能影响整个scheduler
  无 jira 任务, final --> persist 回复一下
  无 jira 任务, final --> persist 少了一个空行
  无 jira 任务, 解决打包冲突 还是有问题, 删掉 gradle
  无 jira 任务, 解决打包冲突
  升级apache工具类
  build.third_step0.gradle edited online with Bitbucket
research/11.0
ju.ju 5 years ago
parent
commit
1dc9cf5efe
  1. 3
      build.third_step0.gradle
  2. 14
      fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/IncTable.java
  3. 5
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfChunk.java
  4. 8
      fine-j2v8/src/com/eclipsesource/v8/PlatformDetector.java
  5. 49
      fine-poi/src/com/fr/third/v2/org/apache/poi/POIXMLTypeLoader.java
  6. 59
      fine-poi/src/com/fr/third/v2/org/apache/poi/util/DocumentHelper.java

3
build.third_step0.gradle

@ -53,8 +53,7 @@ configurations {
} }
dependencies { dependencies {
// @branch - thirdjar "com.fr.third:fine-third-base:10.0-BASE-SNAPSHOT"
thirdjar "com.fr.third:fine-third:10.0-FEATURE-SNAPSHOT"
sigar "com.fr.third:sigar:1.6.0" sigar "com.fr.third:sigar:1.6.0"
testCompile 'junit:junit:4.12' testCompile 'junit:junit:4.12'
} }

14
fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/IncTable.java

@ -105,16 +105,24 @@ public class IncTable {
int ncol = 0; int ncol = 0;
ArrayList c0 = (ArrayList)rows.get(0); ArrayList c0 = (ArrayList)rows.get(0);
ArrayList<Float> colWidths = new ArrayList<Float>(); ArrayList<Float> colWidths = new ArrayList<Float>();
float widthSum = 0;
for (int k = 0; k < c0.size(); ++k) { for (int k = 0; k < c0.size(); ++k) {
PdfPCell pCell = ((PdfPCell)c0.get(k)); PdfPCell pCell = ((PdfPCell)c0.get(k));
int cellCols = pCell.getColspan(); int cellCols = pCell.getColspan();
ncol += cellCols; ncol += cellCols;
//不取 0 ,后面可能需要求比值
float styleWidth = pCell.getStyleWidth();
if(cellCols > 1){ if(cellCols > 1){
float avgWidth = styleWidth / cellCols;
float width = 0 == avgWidth ? 1 : avgWidth;
widthSum = width * cellCols;
for(int a = 0; a < cellCols ; a++){ for(int a = 0; a < cellCols ; a++){
colWidths.add(pCell.getStyleWidth()/cellCols); colWidths.add(width);
} }
}else { }else {
colWidths.add(pCell.getStyleWidth()); float width = 0 == styleWidth ? 1 : styleWidth;
widthSum += width;
colWidths.add(width);
} }
} }
@ -133,7 +141,7 @@ public class IncTable {
float totalWidth = CSSUtils.parseFloat(width); float totalWidth = CSSUtils.parseFloat(width);
float[] floats = new float[colWidths.size()]; float[] floats = new float[colWidths.size()];
for (int a = 0; a < colWidths.size(); a++) { for (int a = 0; a < colWidths.size(); a++) {
floats[a] = colWidths.get(a); floats[a] = totalWidth * colWidths.get(a) / widthSum;
} }
//解析px数值 //解析px数值
table.setTotalWidth(totalWidth); table.setTotalWidth(totalWidth);

5
fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfChunk.java

@ -789,9 +789,10 @@ public class PdfChunk {
public String toHtmlString() { public String toHtmlString() {
StringBuffer htmlString = new StringBuffer(); StringBuffer htmlString = new StringBuffer();
if (this.isImage()) { if (this.isImage()) {
htmlString.append("<img src='").append(image.getSrcString()).append("'").append("/>"); htmlString.append("<img src='").append(image.getSrcString()).append("'").
append(" style='width:").append(image.getPlainWidth()).append("px").
append(" height:").append(image.getPlainHeight()).append("px'").append("/>");
return htmlString.toString(); return htmlString.toString();
} }
//todo 需要添加其他样式属性 //todo 需要添加其他样式属性
htmlString.append("<span style='"); htmlString.append("<span style='");

8
fine-j2v8/src/com/eclipsesource/v8/PlatformDetector.java

@ -125,7 +125,9 @@ public class PlatformDetector {
return "google"; return "google";
} }
throw new UnsatisfiedLinkError("Unsupported vendor: " + getName()); //如果if条件全部不符合,就会陷入死循环,代码存在风险
//throw new UnsatisfiedLinkError("Unsupported vendor: " + getName());
return "";
} }
private static String getLinuxOsReleaseId() { private static String getLinuxOsReleaseId() {
@ -144,7 +146,9 @@ public class PlatformDetector {
return parseLinuxRedhatReleaseFile(file); return parseLinuxRedhatReleaseFile(file);
} }
throw new UnsatisfiedLinkError("Unsupported linux vendor: " + getName()); //linux系统下如果缺失/etc/os-release,/usr/lib/os-release,/etc/redhat-release三个文件,就会和getName方法就会一直互相调用
//throw new UnsatisfiedLinkError("Unsupported linux vendor: " + getName());
return "";
} }
private static String parseLinuxOsReleaseFile(final File file) { private static String parseLinuxOsReleaseFile(final File file) {

49
fine-poi/src/com/fr/third/v2/org/apache/poi/POIXMLTypeLoader.java

@ -18,9 +18,11 @@
package com.fr.third.v2.org.apache.poi; package com.fr.third.v2.org.apache.poi;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.Reader; import java.io.Reader;
import java.io.StringReader;
import java.net.URL; import java.net.URL;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@ -28,6 +30,7 @@ import java.util.Map;
import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamReader;
import com.fr.third.v2.org.apache.poi.util.DocumentHelper;
import com.fr.third.v2.org.apache.xmlbeans.SchemaType; import com.fr.third.v2.org.apache.xmlbeans.SchemaType;
import com.fr.third.v2.org.apache.xmlbeans.XmlBeans; import com.fr.third.v2.org.apache.xmlbeans.XmlBeans;
import com.fr.third.v2.org.apache.xmlbeans.XmlException; import com.fr.third.v2.org.apache.xmlbeans.XmlException;
@ -35,19 +38,26 @@ import com.fr.third.v2.org.apache.xmlbeans.XmlObject;
import com.fr.third.v2.org.apache.xmlbeans.XmlOptions; import com.fr.third.v2.org.apache.xmlbeans.XmlOptions;
import com.fr.third.v2.org.apache.xmlbeans.xml.stream.XMLInputStream; import com.fr.third.v2.org.apache.xmlbeans.xml.stream.XMLInputStream;
import com.fr.third.v2.org.apache.xmlbeans.xml.stream.XMLStreamException; import com.fr.third.v2.org.apache.xmlbeans.xml.stream.XMLStreamException;
import org.w3c.dom.Document;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class POIXMLTypeLoader { public class POIXMLTypeLoader {
public static final XmlOptions DEFAULT_XML_OPTIONS; public static final XmlOptions DEFAULT_XML_OPTIONS;
static { static {
DEFAULT_XML_OPTIONS = new XmlOptions(); DEFAULT_XML_OPTIONS = new XmlOptions();
DEFAULT_XML_OPTIONS.setSaveOuter(); DEFAULT_XML_OPTIONS.setSaveOuter();
DEFAULT_XML_OPTIONS.setUseDefaultNamespace(); DEFAULT_XML_OPTIONS.setUseDefaultNamespace();
DEFAULT_XML_OPTIONS.setSaveAggressiveNamespaces(); DEFAULT_XML_OPTIONS.setSaveAggressiveNamespaces();
DEFAULT_XML_OPTIONS.setCharacterEncoding("UTF-8"); DEFAULT_XML_OPTIONS.setCharacterEncoding("UTF-8");
DEFAULT_XML_OPTIONS.setLoadEntityBytesLimit(4096); // Piccolo is disabled for POI builts, i.e. JAXP is used for parsing
// so only user code using XmlObject/XmlToken.Factory.parse
// directly can bypass the entity check, which is probably unlikely (... and not within our responsibility :))
// DEFAULT_XML_OPTIONS.setLoadEntityBytesLimit(4096);
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<String, String>();
map.put("http://schemas.openxmlformats.org/drawingml/2006/main", "a"); map.put("http://schemas.openxmlformats.org/drawingml/2006/main", "a");
@ -68,8 +78,7 @@ public class POIXMLTypeLoader {
} }
private static XmlOptions getXmlOptions(XmlOptions options) { private static XmlOptions getXmlOptions(XmlOptions options) {
XmlOptions opt = (options == null) ? DEFAULT_XML_OPTIONS : options; return options == null ? DEFAULT_XML_OPTIONS : options;
return opt;
} }
public static XmlObject newInstance(SchemaType type, XmlOptions options) { public static XmlObject newInstance(SchemaType type, XmlOptions options) {
@ -77,19 +86,38 @@ public class POIXMLTypeLoader {
} }
public static XmlObject parse(String xmlText, SchemaType type, XmlOptions options) throws XmlException { public static XmlObject parse(String xmlText, SchemaType type, XmlOptions options) throws XmlException {
return XmlBeans.getContextTypeLoader().parse(xmlText, type, getXmlOptions(options)); try {
return parse(new StringReader(xmlText), type, options);
} catch (IOException e) {
throw new XmlException("Unable to parse xml bean", e);
}
} }
public static XmlObject parse(File file, SchemaType type, XmlOptions options) throws XmlException, IOException { public static XmlObject parse(File file, SchemaType type, XmlOptions options) throws XmlException, IOException {
return XmlBeans.getContextTypeLoader().parse(file, type, getXmlOptions(options)); InputStream is = new FileInputStream(file);
try {
return parse(is, type, options);
} finally {
is.close();
}
} }
public static XmlObject parse(URL file, SchemaType type, XmlOptions options) throws XmlException, IOException { public static XmlObject parse(URL file, SchemaType type, XmlOptions options) throws XmlException, IOException {
return XmlBeans.getContextTypeLoader().parse(file, type, getXmlOptions(options)); InputStream is = file.openStream();
try {
return parse(is, type, options);
} finally {
is.close();
}
} }
public static XmlObject parse(InputStream jiois, SchemaType type, XmlOptions options) throws XmlException, IOException { public static XmlObject parse(InputStream jiois, SchemaType type, XmlOptions options) throws XmlException, IOException {
return XmlBeans.getContextTypeLoader().parse(jiois, type, getXmlOptions(options)); try {
Document doc = DocumentHelper.readDocument(jiois);
return XmlBeans.getContextTypeLoader().parse(doc.getDocumentElement(), type, getXmlOptions(options));
} catch (SAXException e) {
throw new IOException("Unable to parse xml bean", e);
}
} }
public static XmlObject parse(XMLStreamReader xsr, SchemaType type, XmlOptions options) throws XmlException { public static XmlObject parse(XMLStreamReader xsr, SchemaType type, XmlOptions options) throws XmlException {
@ -97,7 +125,12 @@ public class POIXMLTypeLoader {
} }
public static XmlObject parse(Reader jior, SchemaType type, XmlOptions options) throws XmlException, IOException { public static XmlObject parse(Reader jior, SchemaType type, XmlOptions options) throws XmlException, IOException {
return XmlBeans.getContextTypeLoader().parse(jior, type, getXmlOptions(options)); try {
Document doc = DocumentHelper.readDocument(new InputSource(jior));
return XmlBeans.getContextTypeLoader().parse(doc.getDocumentElement(), type, getXmlOptions(options));
} catch (SAXException e) {
throw new XmlException("Unable to parse xml bean", e);
}
} }
public static XmlObject parse(Node node, SchemaType type, XmlOptions options) throws XmlException { public static XmlObject parse(Node node, SchemaType type, XmlOptions options) throws XmlException {

59
fine-poi/src/com/fr/third/v2/org/apache/poi/util/DocumentHelper.java

@ -29,12 +29,55 @@ import javax.xml.stream.events.Namespace;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
public final class DocumentHelper { public final class DocumentHelper {
private static POILogger logger = POILogFactory.getLogger(DocumentHelper.class); private static POILogger logger = POILogFactory.getLogger(DocumentHelper.class);
private DocumentHelper() {} private DocumentHelper() {
}
private static class DocHelperErrorHandler implements ErrorHandler {
public void warning(SAXParseException exception) throws SAXException {
printError(POILogger.WARN, exception);
}
public void error(SAXParseException exception) throws SAXException {
printError(POILogger.ERROR, exception);
}
public void fatalError(SAXParseException exception) throws SAXException {
printError(POILogger.FATAL, exception);
throw exception;
}
/**
* Prints the error message.
*/
private void printError(int type, SAXParseException ex) {
StringBuilder sb = new StringBuilder();
String systemId = ex.getSystemId();
if (systemId != null) {
int index = systemId.lastIndexOf('/');
if (index != -1)
systemId = systemId.substring(index + 1);
sb.append(systemId);
}
sb.append(':');
sb.append(ex.getLineNumber());
sb.append(':');
sb.append(ex.getColumnNumber());
sb.append(": ");
sb.append(ex.getMessage());
logger.log(type, sb.toString(), ex);
}
}
/** /**
* Creates a new document builder, with sensible defaults * Creates a new document builder, with sensible defaults
@ -43,6 +86,7 @@ public final class DocumentHelper {
try { try {
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
documentBuilder.setEntityResolver(SAXHelper.IGNORING_ENTITY_RESOLVER); documentBuilder.setEntityResolver(SAXHelper.IGNORING_ENTITY_RESOLVER);
documentBuilder.setErrorHandler(new DocHelperErrorHandler());
return documentBuilder; return documentBuilder;
} catch (ParserConfigurationException e) { } catch (ParserConfigurationException e) {
throw new IllegalStateException("cannot create a DocumentBuilder", e); throw new IllegalStateException("cannot create a DocumentBuilder", e);
@ -50,6 +94,7 @@ public final class DocumentHelper {
} }
private static final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); private static final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
static { static {
documentBuilderFactory.setNamespaceAware(true); documentBuilderFactory.setNamespaceAware(true);
documentBuilderFactory.setValidating(false); documentBuilderFactory.setValidating(false);
@ -89,6 +134,7 @@ public final class DocumentHelper {
/** /**
* Parses the given stream via the default (sensible) * Parses the given stream via the default (sensible)
* DocumentBuilder * DocumentBuilder
*
* @param inp Stream to read the XML data from * @param inp Stream to read the XML data from
* @return the parsed Document * @return the parsed Document
*/ */
@ -96,6 +142,17 @@ public final class DocumentHelper {
return newDocumentBuilder().parse(inp); return newDocumentBuilder().parse(inp);
} }
/**
* Parses the given stream via the default (sensible)
* DocumentBuilder
*
* @param inp sax source to read the XML data from
* @return the parsed Document
*/
public static Document readDocument(InputSource inp) throws IOException, SAXException {
return newDocumentBuilder().parse(inp);
}
// must only be used to create empty documents, do not use it for parsing! // must only be used to create empty documents, do not use it for parsing!
private static final DocumentBuilder documentBuilderSingleton = newDocumentBuilder(); private static final DocumentBuilder documentBuilderSingleton = newDocumentBuilder();

Loading…
Cancel
Save