Nomi di cartella: azzerare il buffer e fermarsi al primo zero (0.21.2)
Il log diceva 'Outal', 'Incal', 'Outfts': il motore a volte dichiara piu' byte di quelli scritti, quindi si leggevano i residui della chiamata precedente. Da li' veniva anche 'manca la cartella di uscita' in invio. Ora ogni lettura azzera il buffer e si ferma al primo zero; la stessa protezione vale per celle, corpo, HTML, percorsi e allegati.
This commit is contained in:
1 parent
bdebf7a233
commit
5ccc22b040
3 files changed
+41
-16
No files matched your search
@@ -1,6 +1,6 @@
|
||||
Name: harbour-grumpydove
|
||||
Summary: Eudora-style mail interface, mobile prototype
|
||||
Version: 0.21.1
|
||||
Version: 0.21.2
|
||||
Release: 1
|
||||
Group: Qt/Qt
|
||||
# Codice EUPL-1.2; le icone vengono dagli sprite di Eudora, BSD 3-Clause
|
||||
@@ -27,6 +27,13 @@ Icons come from the original project's Eudora bitmaps (BSD 3-Clause,
|
||||
Computer History Museum).
|
||||
|
||||
%changelog
|
||||
* Tue Nov 17 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.21.2-1
|
||||
- Corretto: i nomi delle cartelle letti dal motore erano sporchi dei residui
|
||||
della chiamata precedente ("In" diventava "Incal", "Out" diventava "Outal",
|
||||
e per questo a volte l'invio diceva "manca la cartella di uscita"). Il
|
||||
motore a volte dichiara una lunghezza maggiore del testo scritto: ora il
|
||||
buffer si azzera prima di ogni lettura e ci si ferma al primo zero
|
||||
- Stessa protezione su celle, corpo, HTML, allegati e percorsi
|
||||
* Tue Nov 17 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.21.1-1
|
||||
- Corretto: leggendo una cartella si chiedeva la riga successiva all'ultima e
|
||||
il motore sollevava un CONSTRAINT_ERROR (mail_boxes.adb, B.Order (Row + 1))
|
||||
|
||||
+31
-13
@@ -179,11 +179,12 @@ void EngineBridge::checkMail()
|
||||
void EngineBridge::pollMail()
|
||||
{
|
||||
char buf[8192];
|
||||
memset(buf, 0, sizeof buf);
|
||||
int running = 1;
|
||||
const int n = s_imap_poll ? s_imap_poll(buf, int(sizeof buf) - 1, &running) : 0;
|
||||
|
||||
if (n > 0) {
|
||||
const QString text = QString::fromUtf8(buf, n);
|
||||
const QString text = testoMotore(buf, n);
|
||||
const QStringList lines = text.split('\n', QString::SkipEmptyParts);
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
const QString riga = lines.at(i);
|
||||
@@ -220,6 +221,7 @@ void EngineBridge::pollMail()
|
||||
char nome[512];
|
||||
int depth = 0;
|
||||
for (int i = 0; i < 200; i++) {
|
||||
memset(nome, 0, sizeof nome);
|
||||
if (s_folder(i, &depth, nome, int(sizeof nome) - 1) < 0) break;
|
||||
s_absorb(i);
|
||||
}
|
||||
@@ -350,10 +352,16 @@ bool EngineBridge::moveToTrash(int folder, int row)
|
||||
// Il motore restituisce la lunghezza del testo, non un terminatore: leggere
|
||||
// il buffer fino al primo zero si porta dietro i residui del testo precedente
|
||||
// ("In" che diventa "Incal"). Si legge sempre con la lunghezza.
|
||||
// Il motore dichiara una lunghezza che a volte supera il testo scritto: se il
|
||||
// buffer non è azzerato si leggono i residui della chiamata precedente ("In"
|
||||
// diventava "Incal", "Out" diventava "Outal"). Si azzera il buffer prima di
|
||||
// ogni chiamata e ci si ferma al primo zero.
|
||||
static QString testoMotore(const char *buf, int n)
|
||||
{
|
||||
if (n <= 0) return QString();
|
||||
return QString::fromUtf8(buf, n);
|
||||
int fine = 0;
|
||||
while (fine < n && buf[fine] != '\0') fine++;
|
||||
return QString::fromUtf8(buf, fine);
|
||||
}
|
||||
|
||||
// L'indirizzo di chi ha scritto: il motore da' "Nome\tindirizzo".
|
||||
@@ -395,10 +403,11 @@ QString EngineBridge::cell(int folder, int row, int column)
|
||||
{
|
||||
if (!s_cell) return QString();
|
||||
char buf[2048];
|
||||
memset(buf, 0, sizeof buf);
|
||||
int n = s_cell(folder, row, column, buf, int(sizeof buf) - 1);
|
||||
if (n <= 0) return QString();
|
||||
if (n > int(sizeof buf) - 1) n = int(sizeof buf) - 1;
|
||||
return QString::fromUtf8(buf, n);
|
||||
return testoMotore(buf, n);
|
||||
}
|
||||
|
||||
// Una cartella ha messaggi? Serve solo per decidere se "Local" merita di
|
||||
@@ -420,12 +429,13 @@ QVariantList EngineBridge::folders()
|
||||
char buf[512];
|
||||
int depth = 0;
|
||||
for (int i = 0; i < 200; i++) {
|
||||
memset(buf, 0, sizeof buf);
|
||||
int n = s_folder(i, &depth, buf, int(sizeof buf) - 1);
|
||||
if (n < 0) break;
|
||||
if (n > int(sizeof buf) - 1) n = int(sizeof buf) - 1;
|
||||
Entry e;
|
||||
e.index = i;
|
||||
e.nome = QString::fromUtf8(buf, n);
|
||||
e.nome = testoMotore(buf, n);
|
||||
e.depth = depth;
|
||||
all.append(e);
|
||||
}
|
||||
@@ -507,7 +517,7 @@ int EngineBridge::folderNamed(const QString &nome)
|
||||
char buf[512];
|
||||
int depth = 0;
|
||||
for (int i = 0; i < 500; i++) {
|
||||
buf[0] = '\0';
|
||||
memset(buf, 0, sizeof buf);
|
||||
const int n = s_folder(i, &depth, buf, int(sizeof buf) - 1);
|
||||
if (n < 0) break;
|
||||
if (testoMotore(buf, qMin(n, int(sizeof buf) - 1))
|
||||
@@ -529,7 +539,7 @@ int EngineBridge::folderOut()
|
||||
char buf[512];
|
||||
int depth = 0;
|
||||
for (int i = 0; i < 500; i++) {
|
||||
buf[0] = '\0';
|
||||
memset(buf, 0, sizeof buf);
|
||||
const int n = s_folder(i, &depth, buf, int(sizeof buf) - 1);
|
||||
if (n < 0) break;
|
||||
const QString nome = testoMotore(buf, qMin(n, int(sizeof buf) - 1));
|
||||
@@ -561,7 +571,7 @@ QString EngineBridge::cartelleViste()
|
||||
char buf[512];
|
||||
int depth = 0;
|
||||
for (int i = 0; i < 500; i++) {
|
||||
buf[0] = '\0';
|
||||
memset(buf, 0, sizeof buf);
|
||||
const int n = s_folder(i, &depth, buf, int(sizeof buf) - 1);
|
||||
if (n < 0) break;
|
||||
nomi << testoMotore(buf, qMin(n, int(sizeof buf) - 1));
|
||||
@@ -602,6 +612,7 @@ QString EngineBridge::nomeCartella(int folder)
|
||||
if (!s_folder || folder < 0) return QString();
|
||||
char buf[512];
|
||||
int depth = 0;
|
||||
memset(buf, 0, sizeof buf);
|
||||
const int n = s_folder(folder, &depth, buf, int(sizeof buf) - 1);
|
||||
if (n < 0) return QString();
|
||||
return testoMotore(buf, qMin(n, int(sizeof buf) - 1));
|
||||
@@ -625,6 +636,7 @@ QString EngineBridge::avviaRicerca(const QString &testo)
|
||||
char buf[512];
|
||||
int depth = 0;
|
||||
for (int i = 0; i < 500; i++) {
|
||||
memset(buf, 0, sizeof buf);
|
||||
const int n = s_folder(i, &depth, buf, int(sizeof buf) - 1);
|
||||
if (n < 0) break;
|
||||
posti << QString::number(i);
|
||||
@@ -981,9 +993,10 @@ QString EngineBridge::filtra(int folder)
|
||||
const int id = s_id_of(folder, riga);
|
||||
if (id < 0) continue;
|
||||
char buf[4096];
|
||||
memset(buf, 0, sizeof buf);
|
||||
const int n = s_path(folder, id, buf, int(sizeof buf) - 1);
|
||||
if (n <= 0) continue;
|
||||
const QString percorso = QString::fromUtf8(buf, qMin(n, int(sizeof buf) - 1));
|
||||
const QString percorso = testoMotore(buf, n);
|
||||
if (percorso.isEmpty()) continue;
|
||||
m_filtriArchivia += QStringLiteral("C\t%1\t%2\t%3\n")
|
||||
.arg(folder).arg(id).arg(percorso);
|
||||
@@ -1284,9 +1297,10 @@ QString EngineBridge::percorsoMessaggio(int folder, int row)
|
||||
const int id = s_id_of(folder, row);
|
||||
if (id < 0) return QString();
|
||||
char buf[4096];
|
||||
memset(buf, 0, sizeof buf);
|
||||
const int n = s_path(folder, id, buf, int(sizeof buf) - 1);
|
||||
if (n <= 0) return QString();
|
||||
return QString::fromUtf8(buf, qMin(n, int(sizeof buf) - 1));
|
||||
return testoMotore(buf, n);
|
||||
}
|
||||
|
||||
// Redirect: non è un inoltro, è la ricomposizione dell'originale con gli
|
||||
@@ -1717,7 +1731,7 @@ QString EngineBridge::corpoHtml(int folder, int row)
|
||||
QByteArray buf(1 << 20, '\0'); // 1 MiB: oltre, non vale la pena disegnarlo
|
||||
const int n = s_html(folder, id, buf.data(), buf.size() - 1);
|
||||
if (n <= 0) return QString();
|
||||
return QString::fromUtf8(buf.constData(), qMin(n, buf.size() - 1));
|
||||
return testoMotore(buf.constData(), qMin(n, int(buf.size()) - 1));
|
||||
}
|
||||
|
||||
QString EngineBridge::body(int folder, int row)
|
||||
@@ -1729,20 +1743,23 @@ QString EngineBridge::body(int folder, int row)
|
||||
// ultima istanza, l'HTML grezzo (che la pagina riduce a testo, vedi
|
||||
// qml/js/htmltext.js).
|
||||
if (s_body) {
|
||||
memset(buf, 0, sizeof buf);
|
||||
const int n = s_body(folder, row, buf, int(sizeof buf) - 1);
|
||||
if (n > 0) return QString::fromUtf8(buf, qMin(n, int(sizeof buf) - 1));
|
||||
if (n > 0) return testoMotore(buf, n);
|
||||
}
|
||||
if (!s_id_of) return QString();
|
||||
const int id = s_id_of(folder, row);
|
||||
if (id < 0) return QString();
|
||||
|
||||
if (s_plain) {
|
||||
memset(buf, 0, sizeof buf);
|
||||
const int n = s_plain(folder, id, buf, int(sizeof buf) - 1);
|
||||
if (n > 0) return QString::fromUtf8(buf, qMin(n, int(sizeof buf) - 1));
|
||||
if (n > 0) return testoMotore(buf, n);
|
||||
}
|
||||
if (s_html) {
|
||||
memset(buf, 0, sizeof buf);
|
||||
const int n = s_html(folder, id, buf, int(sizeof buf) - 1);
|
||||
if (n > 0) return QString::fromUtf8(buf, qMin(n, int(sizeof buf) - 1));
|
||||
if (n > 0) return testoMotore(buf, n);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
@@ -1830,6 +1847,7 @@ int EngineBridge::totalUnread()
|
||||
int depth = 0;
|
||||
int total = 0;
|
||||
for (int i = 0; i < 200; i++) {
|
||||
memset(buf, 0, sizeof buf);
|
||||
int n = s_folder(i, &depth, buf, int(sizeof buf) - 1);
|
||||
if (n < 0) break;
|
||||
if (depth == 0) total += s_unread(i); // gli account sommano già le cartelle
|
||||
|
||||
+2
-2
@@ -32,9 +32,9 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
|
||||
|
||||
app->setOrganizationName(QStringLiteral("harbour"));
|
||||
app->setApplicationName(QStringLiteral("grumpydove"));
|
||||
app->setApplicationVersion(QStringLiteral("0.21.1"));
|
||||
app->setApplicationVersion(QStringLiteral("0.21.2"));
|
||||
|
||||
qDebug() << "harbour-grumpydove v0.21.1 build" << __DATE__ << __TIME__;
|
||||
qDebug() << "harbour-grumpydove v0.21.2 build" << __DATE__ << __TIME__;
|
||||
|
||||
// Maildir, log, rubrica e liste dei filtri nella cartella dati dell'app:
|
||||
// la sandbox non lascia vedere ~/Mail né scrivere sotto HOME, e cambiare
|
||||
|
||||
Reference in new issue
Block a user