Skip to content

Commit 247f29b

Browse files
dunaj-devclaude
andcommitted
Fix parsing issues with binary control characters
- Update alias parsing to handle binary control characters in Docker output - Fix email accounts parsing to be more resilient to special characters - Replace startsWith check with includes for more reliable matching - Add regex clean-up to remove control characters (0x00-0x1F, 0x7F-0x9F) - Remove strict ^ anchor from regex to allow parsing entries with prefixed binary data 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent be3f5f1 commit 247f29b

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

backend/dockerMailserver.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,18 @@ async function getAccounts() {
9191

9292
// Parse multiline output with regex to extract email and size information
9393
const accounts = [];
94-
const accountLineRegex = /^\* ([\w\-\.@]+) \( ([\w\~]+) \/ ([\w\~]+) \) \[(\d+)%\](.*)$/;
94+
const accountLineRegex = /\* ([\w\-\.@]+) \( ([\w\~]+) \/ ([\w\~]+) \) \[(\d+)%\](.*)$/;
9595

9696
// Process each line individually
9797
const lines = stdout.split('\n').filter(line => line.trim().length > 0);
9898
debugLog('Raw email list response:', lines);
9999

100100
for (let i = 0; i < lines.length; i++) {
101-
const line = lines[i].trim();
101+
// Clean the line from binary control characters
102+
const line = lines[i].replace(/[\x00-\x1F\x7F-\x9F]/g, '').trim();
102103

103-
// Check if line starts with * which indicates an account entry
104-
if (line.startsWith('*')) {
104+
// Check if line contains * which indicates an account entry
105+
if (line.includes('*')) {
105106
const match = line.match(accountLineRegex);
106107

107108
if (match) {
@@ -173,12 +174,15 @@ async function getAliases() {
173174
// Parse each line in the format "* source destination"
174175
const lines = stdout.split('\n').filter(line => line.trim().length > 0);
175176
debugLog('Raw alias list response:', lines);
176-
const aliasRegex = /^\* ([\w\-\.@]+) ([\w\-\.@]+)$/;
177+
178+
// Modified regex to be more tolerant of control characters that might appear in the output
179+
const aliasRegex = /\* ([\w\-\.@]+) ([\w\-\.@]+)$/;
177180

178181
for (let i = 0; i < lines.length; i++) {
179-
const line = lines[i].trim();
182+
// Clean the line from binary control characters
183+
const line = lines[i].replace(/[\x00-\x1F\x7F-\x9F]/g, '').trim();
180184

181-
if (line.startsWith('*')) {
185+
if (line.includes('*')) {
182186
const match = line.match(aliasRegex);
183187
if (match) {
184188
const source = match[1];

0 commit comments

Comments
 (0)