private void processAcroField(PDField field, final int currentRecursiveDepth) throws SAXException, IOException, TikaException { if (currentRecursiveDepth >= MAX_ACROFORM_RECURSIONS) { return; } PDFormFieldAdditionalActions pdFormFieldAdditionalActions = field.getActions(); if (pdFormFieldAdditionalActions != null) { handleDestinationOrAction(pdFormFieldAdditionalActions.getC(), ActionTrigger.FORM_FIELD_RECALCULATE); handleDestinationOrAction(pdFormFieldAdditionalActions.getF(), ActionTrigger.FORM_FIELD_FORMATTED); handleDestinationOrAction(pdFormFieldAdditionalActions.getK(), ActionTrigger.FORM_FIELD_KEYSTROKE); handleDestinationOrAction(pdFormFieldAdditionalActions.getV(), ActionTrigger.FORM_FIELD_VALUE_CHANGE); } if (field.getWidgets() != null) { for (PDAnnotationWidget widget : field.getWidgets()) { handleWidget(widget); } } addFieldString(field); if (field instanceof PDNonTerminalField) { int r = currentRecursiveDepth + 1; xhtml.startElement("ol"); for (PDField child : ((PDNonTerminalField)field).getChildren()) { processAcroField(child, r); } xhtml.endElement("ol"); } }
private List<PDAction> getAdditionalAction() { PDFormFieldAdditionalActions pbActions = ((PDField) this.simplePDObject) .getActions(); if (pbActions != null) { List<PDAction> actions = new ArrayList<>(MAX_NUMBER_OF_ACTIONS); org.apache.pdfbox.pdmodel.interactive.action.PDAction buffer; buffer = pbActions.getC(); this.addAction(actions, buffer); buffer = pbActions.getF(); this.addAction(actions, buffer); buffer = pbActions.getK(); this.addAction(actions, buffer); buffer = pbActions.getV(); this.addAction(actions, buffer); return Collections.unmodifiableList(actions); } return Collections.emptyList(); }
void sanitizeFieldAdditionalActions(PDFormFieldAdditionalActions fieldActions) { if (fieldActions.getC() != null) { LOGGER.debug( "Found&removed an action to be performed in order to recalculate the value of this field when that of another field changes."); fieldActions.setC(null); pdfBleachSession.recordJavascriptThreat("FormAdditionalActions", "Action on value change"); } if (fieldActions.getF() != null) { LOGGER.debug( "Found&removed an action to be performed before the field is formatted to display its current value."); fieldActions.setF(null); pdfBleachSession .recordJavascriptThreat("FormAdditionalActions", "Action to format the value"); } if (fieldActions.getK() != null) { LOGGER.debug( "Found&removed an action to be performed when the user types a keystroke into a text field or combo box or modifies the selection in a scrollable list box."); fieldActions.setK(null); pdfBleachSession .recordJavascriptThreat("FormAdditionalActions", "Action when the user types a keystoke"); } if (fieldActions.getV() != null) { LOGGER.debug( "Found&removed an action to be action to be performed when the field's value is changed."); fieldActions.setV(null); pdfBleachSession.recordJavascriptThreat("FormAdditionalActions", "Action when the field's value is changed"); } }
private void processAcroField(PDField field, final int currentRecursiveDepth) throws SAXException, IOException, TikaException { if (currentRecursiveDepth >= MAX_ACROFORM_RECURSIONS) { return; } PDFormFieldAdditionalActions pdFormFieldAdditionalActions = field.getActions(); if (pdFormFieldAdditionalActions != null) { handleDestinationOrAction(pdFormFieldAdditionalActions.getC(), ActionTrigger.FORM_FIELD_RECALCULATE); handleDestinationOrAction(pdFormFieldAdditionalActions.getF(), ActionTrigger.FORM_FIELD_FORMATTED); handleDestinationOrAction(pdFormFieldAdditionalActions.getK(), ActionTrigger.FORM_FIELD_KEYSTROKE); handleDestinationOrAction(pdFormFieldAdditionalActions.getV(), ActionTrigger.FORM_FIELD_VALUE_CHANGE); } if (field.getWidgets() != null) { for (PDAnnotationWidget widget : field.getWidgets()) { handleWidget(widget); } } addFieldString(field); if (field instanceof PDNonTerminalField) { int r = currentRecursiveDepth + 1; xhtml.startElement("ol"); for (PDField child : ((PDNonTerminalField)field).getChildren()) { processAcroField(child, r); } xhtml.endElement("ol"); } }
private void processAcroField(PDField field, final int currentRecursiveDepth) throws SAXException, IOException, TikaException { if (currentRecursiveDepth >= MAX_ACROFORM_RECURSIONS) { return; } PDFormFieldAdditionalActions pdFormFieldAdditionalActions = field.getActions(); if (pdFormFieldAdditionalActions != null) { handleDestinationOrAction(pdFormFieldAdditionalActions.getC(), ActionTrigger.FORM_FIELD_RECALCULATE); handleDestinationOrAction(pdFormFieldAdditionalActions.getF(), ActionTrigger.FORM_FIELD_FORMATTED); handleDestinationOrAction(pdFormFieldAdditionalActions.getK(), ActionTrigger.FORM_FIELD_KEYSTROKE); handleDestinationOrAction(pdFormFieldAdditionalActions.getV(), ActionTrigger.FORM_FIELD_VALUE_CHANGE); } if (field.getWidgets() != null) { for (PDAnnotationWidget widget : field.getWidgets()) { handleWidget(widget); } } addFieldString(field); if (field instanceof PDNonTerminalField) { int r = currentRecursiveDepth + 1; xhtml.startElement("ol"); for (PDField child : ((PDNonTerminalField)field).getChildren()) { processAcroField(child, r); } xhtml.endElement("ol"); } }
private void processAcroField(PDField field, final int currentRecursiveDepth) throws SAXException, IOException, TikaException { if (currentRecursiveDepth >= MAX_ACROFORM_RECURSIONS) { return; } PDFormFieldAdditionalActions pdFormFieldAdditionalActions = field.getActions(); if (pdFormFieldAdditionalActions != null) { handleDestinationOrAction(pdFormFieldAdditionalActions.getC(), ActionTrigger.FORM_FIELD_RECALCULATE); handleDestinationOrAction(pdFormFieldAdditionalActions.getF(), ActionTrigger.FORM_FIELD_FORMATTED); handleDestinationOrAction(pdFormFieldAdditionalActions.getK(), ActionTrigger.FORM_FIELD_KEYSTROKE); handleDestinationOrAction(pdFormFieldAdditionalActions.getV(), ActionTrigger.FORM_FIELD_VALUE_CHANGE); } if (field.getWidgets() != null) { for (PDAnnotationWidget widget : field.getWidgets()) { handleWidget(widget); } } addFieldString(field); if (field instanceof PDNonTerminalField) { int r = currentRecursiveDepth + 1; xhtml.startElement("ol"); for (PDField child : ((PDNonTerminalField)field).getChildren()) { processAcroField(child, r); } xhtml.endElement("ol"); } }