Skip to content

Commit

Permalink
Version: 4.0.4 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
gh0stkey committed Jan 17, 2025
1 parent 452f297 commit 5977e82
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/main/java/hae/HaE.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class HaE implements BurpExtension {
public void initialize(MontoyaApi api) {
// 设置扩展名称
api.extension().setName("HaE - Highlighter and Extractor");
String version = "4.0.3";
String version = "4.0.4";

// 加载扩展后输出的项目信息
Logging logging = api.logging();
Expand Down
38 changes: 23 additions & 15 deletions src/main/java/hae/component/board/table/Datatable.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class Datatable extends JPanel {
private final JTextField secondSearchField;
private final TableRowSorter<DefaultTableModel> sorter;
private final JCheckBox searchMode = new JCheckBox("Reverse search");
private final JCheckBox regexMode = new JCheckBox("Regex mode");
private final String tabName;
private final JPanel footerPanel;

Expand All @@ -52,7 +53,7 @@ public Datatable(MontoyaApi api, ConfigLoader configLoader, String tabName, List

private void initComponents(List<String> dataList) {
dataTable.setRowSorter(sorter);

// 设置ID排序
sorter.setComparator(0, new Comparator<Integer>() {
@Override
Expand Down Expand Up @@ -119,10 +120,12 @@ public void changedUpdate(DocumentEvent e) {
optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.X_AXIS));

// Settings按钮
JPanel settingMenuPanel = new JPanel(new GridLayout(1, 1));
JPanel settingMenuPanel = new JPanel(new GridLayout(2, 1));
settingMenuPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
JPopupMenu settingMenu = new JPopupMenu();
settingMenuPanel.add(searchMode);
settingMenuPanel.add(regexMode);
regexMode.setSelected(true);
searchMode.addItemListener(e -> performSearch());
settingMenu.add(settingMenuPanel);

Expand Down Expand Up @@ -163,8 +166,8 @@ private void addRowToTable(Object[] data) {
}

private void performSearch() {
RowFilter<Object, Object> firstRowFilter = getObjectObjectRowFilter(searchField);
RowFilter<Object, Object> secondRowFilter = getObjectObjectRowFilter(secondSearchField);
RowFilter<Object, Object> firstRowFilter = getObjectObjectRowFilter(searchField, true);
RowFilter<Object, Object> secondRowFilter = getObjectObjectRowFilter(secondSearchField, false);
if (searchField.getForeground().equals(Color.BLACK)) {
sorter.setRowFilter(firstRowFilter);
if (secondSearchField.getForeground().equals(Color.BLACK)) {
Expand All @@ -176,24 +179,29 @@ private void performSearch() {
}
}

private RowFilter<Object, Object> getObjectObjectRowFilter(JTextField searchField) {
private RowFilter<Object, Object> getObjectObjectRowFilter(JTextField searchField, boolean firstFlag) {
return new RowFilter<Object, Object>() {
public boolean include(Entry<?, ?> entry) {
String searchFieldTextText = searchField.getText();
Pattern pattern = null;
try {
pattern = Pattern.compile(searchFieldTextText, Pattern.CASE_INSENSITIVE);
} catch (Exception ignored) {
}

String entryValue = ((String) entry.getValue(1)).toLowerCase();
searchFieldTextText = searchFieldTextText.toLowerCase();
String entryValue = ((String) entry.getValue(1)).toLowerCase();
boolean filterReturn = searchFieldTextText.isEmpty();
if (pattern != null) {
filterReturn = filterReturn || pattern.matcher(entryValue).find() != searchMode.isSelected();
boolean firstFlagReturn = searchMode.isSelected() && firstFlag;
if (regexMode.isSelected()) {
Pattern pattern = null;
try {
pattern = Pattern.compile(searchFieldTextText, Pattern.CASE_INSENSITIVE);
} catch (Exception ignored) {
}

if (pattern != null) {
filterReturn = filterReturn || pattern.matcher(entryValue).find() != firstFlagReturn;
}
} else {
filterReturn = filterReturn || entryValue.contains(searchFieldTextText) != firstFlagReturn;
}

return filterReturn || entryValue.contains(searchFieldTextText) != searchMode.isSelected();
return filterReturn;
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/hae/utils/DataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private void loadHaEData(PersistedList<String> dataIndex) {
RegularMatcher.putDataToGlobalMap(api, index, dataKey, dataObj.getStringList(dataKey).stream().toList(), false);
});
} catch (Exception e) {
api.logging().logToOutput("loadHaEData:" + e.getMessage());
// api.logging().logToOutput("loadHaEData:" + e.getMessage());
}
});
}
Expand Down

0 comments on commit 5977e82

Please sign in to comment.