Skip to content

Commit

Permalink
## [v1.1.15] - 2024-01-24
Browse files Browse the repository at this point in the history
- bugfix: fixed bug in related to misuse of displaying icons in StyledDocument
  • Loading branch information
gdgd009xcd authored Jan 24, 2024
2 parents cbef655 + 80bc5f8 commit 6bdccb5
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 66 deletions.
6 changes: 5 additions & 1 deletion addOns/automacrobuilder/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
All notable changes to this add-on will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [v1.1.14] - 2023-12-14
## [v1.1.15] - 2024-01-24
### Changed
- bugfix: fixed bug in related to misuse of displaying icons in StyledDocument

## [v1.1.14] - 2024-01-15
### Added
- improve: Added javahelp [?] button on the right-top corner of the MacroBuilder tab
### Changed
Expand Down
2 changes: 1 addition & 1 deletion addOns/automacrobuilder/automacrobuilder.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import org.zaproxy.gradle.addon.AddOnStatus

version = "1.1.14"
version = "1.1.15"
description = "AutoMacroBuilder for ZAP"

tasks.withType<JavaCompile> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public PRequest(String h, int p, boolean ssl, byte[] _binmessage, Encode _pageen
}

/**
* handover chunks, doctext from chunkdoc to this instance
* create instance
* pass argument chunkdoc, extract doctext from chunkdoc
*
* @param h
* @param p
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class PResponse extends ParseHTTPHeaders {
private ParmGenGSONDecoder jsonparser = null;

public static final int MAX_SIZE_RESPONSE_CONTENTS = 25000;
private static final int MAX_SIZE_DISPLAYABLE_TEXTS = 100000;

public PResponse(byte[] bin, Encode _pageenc) {
super(bin, _pageenc);
Expand All @@ -40,7 +41,7 @@ public PResponse(byte[] bin, Encode _pageenc) {
jsonparser = null;
}

// Location headerのパラメータ取得
// get Location header value
public <T> InterfaceCollection<T> getLocationTokens(InterfaceCollection<T> tklist) {
String locheader = getHeader("Location");

Expand Down Expand Up @@ -179,13 +180,14 @@ public List<PResponse.ResponseChunk> getResponseChunks() {
return getResponseChunks(theaders, tbodies, tcontent_type);
}

public List<PResponse.ResponseChunk> getResponseChunks(
private List<PResponse.ResponseChunk> getResponseChunks(
String theaders, byte[] tbodies, String tcontent_type) {
List<PResponse.ResponseChunk> reschunks = new ArrayList<>();

String mediaType = getContentMimeType();
String displayableImageContents = "";
String application_json_contents = "";
String text_contents = "";
if (tcontent_type != null && !tcontent_type.isEmpty()) {
LOGGER4J.debug("content-type[" + tcontent_type + "]");
List<String> matches =
Expand All @@ -194,17 +196,24 @@ public List<PResponse.ResponseChunk> getResponseChunks(
displayableImageContents = matches.get(0);
}
List<String> jsonmatches =
ParmGenUtil.getRegexMatchGroups("application/(json)", tcontent_type);
ParmGenUtil.getRegexMatchGroups("application/(json|javascript)", tcontent_type);
if (jsonmatches.size() > 0) {
application_json_contents = jsonmatches.get(0);
}
List<String> textmatches =
ParmGenUtil.getRegexMatchGroups("application/(\\w)", tcontent_type);
if (jsonmatches.size() > 0) {
application_json_contents = jsonmatches.get(0);
}
}

boolean displayableTextContents = false;
if (mediaType.equalsIgnoreCase("text/html")) {
displayableTextContents = true;
} else if (!application_json_contents.isEmpty()) {
displayableTextContents = true;
if (tbodies.length < MAX_SIZE_DISPLAYABLE_TEXTS) {
if (mediaType.equalsIgnoreCase("text/html")) {
displayableTextContents = true;
} else if (!application_json_contents.isEmpty()) {
displayableTextContents = true;
}
}

int partno = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class MacroBuilderUI extends javax.swing.JPanel implements InterfacePar

int EditTarget = -1;
Encode EditPageEnc = Encode.ISO_8859_1;
static final int REQUEST_DISPMAXSIZ = 500000;//1MB
static final int REQUEST_DISPMAXSIZ = 500000;//0.5MB
static final int RESPONSE_DISPMAXSIZ = 1000000;//1MB

JPanel plusBtnPanel = null;
Expand Down Expand Up @@ -240,6 +240,7 @@ public void clear() {

messageRequest.setText("");
messageResponse.setText("");

MacroComments.setText("");
this.pmtProvider.clear();
this.maxTabIndex = 0;
Expand Down Expand Up @@ -473,7 +474,7 @@ private void initComponents() {
RequestList = new javax.swing.JList<>();
generalHelpBtn = new JButton(QUESTION_BUTTON_ICON);


messageResponse.setEditable(false);

generalHelpBtn.addActionListener(new ActionListener() {
@Override
Expand Down Expand Up @@ -1801,7 +1802,10 @@ private void showActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:ev
String orig = messageResponse.getText();
if (pos != -1) {
StyledDocument doc = messageResponse.getStyledDocument();
new ParmGenRegex(this,reg,doc).setVisible(true);
if (doc instanceof StyledDocumentWithChunk) {
StyledDocumentWithChunk newchunkdoc = new StyledDocumentWithChunk((StyledDocumentWithChunk) doc);
new ParmGenRegex(this, reg, newchunkdoc).setVisible(true);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

/**
*
* @author tms783
* @author gdgd009xcd
*/
@SuppressWarnings("serial")
public class ParmGenRegex extends javax.swing.JDialog {
Expand Down Expand Up @@ -212,12 +212,17 @@ public ParmGenRegex(InterfaceParmGenRegexSaveCancelAction _actionwin, String _re
SwingStyle.clearAllCharacterAttributes(doc);

OriginalText.setCaretPosition(0);


boolean hasBinaryContents = false;
isLabelSaveBtn = false;
if (doc instanceof StyledDocumentWithChunk) {
this.docwithchunk = CastUtils.castToType(doc);
hasBinaryContents = this.docwithchunk.hasBinaryContents();
isLabelSaveBtn = this.docwithchunk.isRequest();
}
if(hasBinaryContents) {
RegexTest.setEnabled(false);
}

addHexView(isLabelSaveBtn);

Expand Down Expand Up @@ -284,7 +289,7 @@ public static String getParsedRegexRaw(String orig, String quant){
for(int i = 0;i < patterns.length; i++){
for(int j = 0 ; j< 2; j++){
String strpattern = patterns[i] + grpclose[j];
Pattern pattern = ParmGenUtil.Pattern_compile(strpattern);//数値
Pattern pattern = ParmGenUtil.Pattern_compile(strpattern);// number
Matcher matcher = pattern.matcher(orig);
if (matcher.find()){
regex = matcher.group();
Expand All @@ -310,7 +315,7 @@ public static String getParsedRegexRaw(String orig, String quant){

int hasGroupRegex(String r){
// (?:^|[^\\])(\([^?].*?\)|\(\))
String greg = "(?:^|[^\\\\])(\\([^?].*?\\)|\\(\\))";//後方参照グループ
String greg = "(?:^|[^\\\\])(\\([^?].*?\\)|\\(\\))";//back-reference group
Pattern pattern = ParmGenUtil.Pattern_compile(greg);
Matcher matcher = pattern.matcher(r);
int gtotal = 0;
Expand Down Expand Up @@ -873,7 +878,7 @@ private void AddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:eve
regprefix = "(?:\\r|\\n|.)";

}else{
regprefix = "\\s";//ホワイトスペース(改行含む)
regprefix = "\\s";//white space(which contains \t \r \n \f)
}

String minmatch = "";
Expand Down Expand Up @@ -1013,13 +1018,13 @@ private void RegexTextKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event
// TODO add your handling code here:

switch (evt.getKeyCode()) {
case KeyEvent.VK_Z: //CTRL+Zのとき、UNDO実行
case KeyEvent.VK_Z: //Undo when Ctrl+Z key is pressed.
if (evt.isControlDown() && um.canUndo()) {
um.undo();
evt.consume();
}
break;
case KeyEvent.VK_Y: //CTRL+Yのとき、REDO実行
case KeyEvent.VK_Y: //Undo when CTRL+Y key is pressed.
if (evt.isControlDown() && um.canRedo()) {
um.redo();
}
Expand Down
Loading

0 comments on commit 6bdccb5

Please sign in to comment.