madExcept settings editor truncates mail body custom string

delphi package - automated exception handling
Post Reply
jarrod-ca
Posts: 6
Joined: Thu Feb 25, 2016 3:42 am

madExcept settings editor truncates mail body custom string

Post by jarrod-ca »

madExcept 4.0.13, Delphi 10 Seattle

If I customize the "send - mail body" string to the following then it is saved correctly to the .mes file but gets truncated when you next edit the settings. If you make any changes to the settings (even something else) then it saves the truncated value to the .mes file. As a work-around I have to revert the MailBody= line in the .mes file before committing any changes to source control.

Example "send - mail body" custom string (ignore the ====== lines):

======
Dear Support,

An unexpected error occurred in XXXXXXXX. Please find the error report attached.

>> Error summary
Application: %appname% version: %appversion%
Exception: %exceptClass%
Exception Message: %exceptMsg%

>> What were you doing when the error occurred?
%errorDetails%
======

The .mes file has:
MailBody=Dear Support,%0d%0a%0d%0aAn unexpected error occurred in XXXXXXXX. Please find the error report attached.%0d%0a%0d%0a>> Error summary%0d%0aApplication: %25appname%25 version: %25appversion%25%0d%0aException: %25exceptClass%25%0d%0aException Message: %25exceptMsg%25%0d%0a%0d%0a>> What were you doing when the error occurred?%0d%0a%25errorDetails%25

When opening the settings editor again the last two lines are truncated and displayed in the editor as:

======
>> What were
======

And if settings are saved the entry in the .mes file changes to:
MailBody=Dear Support,%0d%0a%0d%0aAn unexpected error occurred in XXXXXXXX. Please find the error report attached.%0d%0a%0d%0a>> Error summary%0d%0aApplication: %25appname%25 version: %25appversion%25%0d%0aException: %25exceptClass%25%0d%0aException Message: %25exceptMsg%25%0d%0a%0d%0a>> What were

The length of the truncation is dependent on the number of encoded characters. Use fewer linefeeds or '%' constants and it truncates less. I am guessing that it truncating the encoded string to the number of decoded characters. e.g. above there are about 30 encoded characters and it truncates by about 60 decoded characters.
rsassen
Posts: 24
Joined: Fri Jun 20, 2014 2:41 pm

Re: madExcept settings editor truncates mail body custom str

Post by rsassen »

I experience the same problem for the ExceptionMessage setting in the .mes file. It also gets truncated sometimes.
jarrod-ca
Posts: 6
Joined: Thu Feb 25, 2016 3:42 am

Re: madExcept settings editor truncates mail body custom str

Post by jarrod-ca »

The truncated strings are also saved to the registry (if saving as "defaults"), so it is not limited to the file load/save.

On a related note the non-printable characters are not encoded in the string values saved in the registry and therefore they cannot be edited using regedit. You can cursor through each carriage return and linefeed character but you can't type them and can't copy/paste them, so I couldn't fix the default settings this way (without resorting to other encoded character entry techniques). I would have thought that it would make sense to encode them in the registry like they are encoded in the .mes file.
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Re: madExcept settings editor truncates mail body custom str

Post by madshi »

I've just tried to reproduce this problem, but I can't. It seems to work fine on my PC. Here's what I did:

1) Created a brand new Delphi 10 Seattle project.
2) Saved it.
3) Edited the mes file and copied in your text for the mail body, including those %0d%0a stuff etc.
4) Opened the project in Delphi 10.
5) The text is shown properly in the madExcept settings dialog.

How can I reproduce the problem on my PC?
jarrod-ca
Posts: 6
Joined: Thu Feb 25, 2016 3:42 am

Re: madExcept settings editor truncates mail body custom str

Post by jarrod-ca »

madshi wrote:How can I reproduce the problem on my PC?
Thanks for looking into it.

The truncation happens when the madExcept settings dialog is opened. The .mes file can be correct but on opening the settings dialog the value displayed in both the value column of "string list" and editable value in "you can edit the strings here" are truncated. If you then save the settings the value will be truncated in the saved .mes file.

I did some testing like this:
1) Edit MailBody value in the .mes file, trying different lengths
2) Close and re-open the project in Delphi
3) Open the madExcept settings dialog and navigate to custom strings, send - mail body.
4) Observe that the value is truncated.
Then repeat steps 1-4 with different values in the .mes file to find different behaviour.

It seems that:
- It is only a problem for long values greater than ~280 characters. If I make it shorter then it is ok and not truncated. If longer then it starts truncating.
- The truncated length is not consistent. Sometimes if I move a %0d%0a to a bit later in the string the amount of truncation changes a lot.

Here is another example where it truncates (truncated after the last '1'):
MailBody=1234567890 1234567890 1234567890 1234567890 1234567890%0d%0a1234567890 1234567890 1234567890 1234567890 1234567890%0d%0a1234567890 1234567890 1234567890 1234567890 1234567890%0d%0a1234567890 1234567890 1234567890 1234567890 1234567890%0d%0a1234567890 1234567890 1234567890

Strangely, in some cases where the string is truncated at the position of a linefeed the last few characters displayed in the editable value in the dialog (and saved to the .mes if you click OK) file are %LF or %L, like the %LF% encoding used in the value column of the "string list" section in the dialog. This might provide a clue - perhaps there is a mix of encodings and the length of one is being applied to the other.
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Re: madExcept settings editor truncates mail body custom str

Post by madshi »

The problem is that I simply cannot reproduce it on my PC. I've tried with a length of > 500 characters, and I can't manage to get the truncation to occur... :(
Post Reply