mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-25 08:37:30 +09:00
Bug 1495698 - Fix hang when HTML signature references non-existent image.
Tag #1273
This commit is contained in:
parent
84617f965f
commit
3a92a80285
2 changed files with 47 additions and 40 deletions
|
|
@ -4350,45 +4350,52 @@ nsMsgCompose::LoadDataFromFile(nsIFile *file, nsString &sigData,
|
||||||
* images loaded into the editor are available on send.
|
* images loaded into the editor are available on send.
|
||||||
*/
|
*/
|
||||||
nsresult
|
nsresult
|
||||||
nsMsgCompose::ReplaceFileURLs(nsAutoString &aData)
|
nsMsgCompose::ReplaceFileURLs(nsString &aData)
|
||||||
{
|
{
|
||||||
int32_t fPos;
|
int32_t fPos;
|
||||||
int32_t offset = -1;
|
int32_t offset = -1; // We're using RFind(), so offset -1 is from the very right.
|
||||||
|
|
||||||
|
// XXX This code is rather incomplete since it looks for "file://" even
|
||||||
|
// outside tags.
|
||||||
while ((fPos = aData.RFind("file://", true, offset)) != kNotFound) {
|
while ((fPos = aData.RFind("file://", true, offset)) != kNotFound) {
|
||||||
if (fPos != kNotFound && fPos > 0) {
|
bool quoted = false;
|
||||||
char16_t q = aData.CharAt(fPos - 1);
|
char16_t q = 'x'; // initialise to anything to keep compilers happy.
|
||||||
bool quoted = (q == '"' || q == '\'');
|
if (fPos > 0) {
|
||||||
int32_t end = kNotFound;
|
q = aData.CharAt(fPos - 1);
|
||||||
if (quoted) {
|
quoted = (q == '"' || q == '\'');
|
||||||
end = aData.FindChar(q, fPos);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int32_t spacePos = aData.FindChar(' ', fPos);
|
|
||||||
int32_t gtPos = aData.FindChar('>', fPos);
|
|
||||||
if (gtPos != kNotFound && spacePos != kNotFound) {
|
|
||||||
end = (spacePos < gtPos) ? spacePos : gtPos;
|
|
||||||
}
|
|
||||||
else if (gtPos == kNotFound && spacePos != kNotFound) {
|
|
||||||
end = spacePos;
|
|
||||||
}
|
|
||||||
else if (gtPos != kNotFound && spacePos == kNotFound) {
|
|
||||||
end = gtPos;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (end == kNotFound) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
nsString fileURL;
|
|
||||||
fileURL = Substring(aData, fPos, end - fPos);
|
|
||||||
nsString dataURL;
|
|
||||||
nsresult rv = DataURLForFileURL(fileURL, dataURL);
|
|
||||||
// If this one failed, maybe because the file wasn't found,
|
|
||||||
// continue to process the next one.
|
|
||||||
if (NS_SUCCEEDED(rv)) {
|
|
||||||
aData.Replace(fPos, end - fPos, dataURL);
|
|
||||||
}
|
|
||||||
offset = fPos - 1;
|
|
||||||
}
|
}
|
||||||
|
int32_t end = kNotFound;
|
||||||
|
if (quoted) {
|
||||||
|
end = aData.FindChar(q, fPos);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int32_t spacePos = aData.FindChar(' ', fPos);
|
||||||
|
int32_t gtPos = aData.FindChar('>', fPos);
|
||||||
|
if (gtPos != kNotFound && spacePos != kNotFound) {
|
||||||
|
end = (spacePos < gtPos) ? spacePos : gtPos;
|
||||||
|
}
|
||||||
|
else if (gtPos == kNotFound && spacePos != kNotFound) {
|
||||||
|
end = spacePos;
|
||||||
|
}
|
||||||
|
else if (gtPos != kNotFound && spacePos == kNotFound) {
|
||||||
|
end = gtPos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (end == kNotFound) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
nsString fileURL;
|
||||||
|
fileURL = Substring(aData, fPos, end - fPos);
|
||||||
|
nsString dataURL;
|
||||||
|
nsresult rv = DataURLForFileURL(fileURL, dataURL);
|
||||||
|
// If this one failed, maybe because the file wasn't found,
|
||||||
|
// continue to process the next one.
|
||||||
|
if (NS_SUCCEEDED(rv)) {
|
||||||
|
aData.Replace(fPos, end - fPos, dataURL);
|
||||||
|
}
|
||||||
|
if (fPos == 0)
|
||||||
|
break;
|
||||||
|
offset = fPos - 1;
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ protected:
|
||||||
nsresult MoveToAboveQuote(void);
|
nsresult MoveToAboveQuote(void);
|
||||||
nsresult MoveToBeginningOfDocument(void);
|
nsresult MoveToBeginningOfDocument(void);
|
||||||
nsresult MoveToEndOfDocument(void);
|
nsresult MoveToEndOfDocument(void);
|
||||||
nsresult ReplaceFileURLs(nsAutoString &sigData);
|
nsresult ReplaceFileURLs(nsString &sigData);
|
||||||
nsresult DataURLForFileURL(const nsAString &aFileURL, nsAString &aDataURL);
|
nsresult DataURLForFileURL(const nsAString &aFileURL, nsAString &aDataURL);
|
||||||
|
|
||||||
// 3 = To, Cc, Bcc
|
// 3 = To, Cc, Bcc
|
||||||
|
|
@ -147,7 +147,7 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////
|
||||||
// THIS IS THE CLASS THAT IS THE STREAM Listener OF THE HTML OUPUT
|
// THIS IS THE CLASS THAT IS THE STREAM Listener OF THE HTML OUTPUT
|
||||||
// FROM LIBMIME. THIS IS FOR QUOTING
|
// FROM LIBMIME. THIS IS FOR QUOTING
|
||||||
////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////
|
||||||
class QuotingOutputStreamListener : public nsIMsgQuotingOutputStreamListener
|
class QuotingOutputStreamListener : public nsIMsgQuotingOutputStreamListener
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue