FogBugz submission now MIME in 4.0.14

delphi package - automated exception handling
Post Reply
FredS
Posts: 98
Joined: Mon May 11, 2015 9:42 pm

FogBugz submission now MIME in 4.0.14

Post by FredS »

Hi Mathias,

Installed 4.0.14 and tested this: viewtopic.php?f=4&t=28111
the new LastHttpPostReply works but the submission shows up as mime not text in FogBugz.

Tested a 4.0.13 build and all works normal so FogBugz didn't' change :)

thanks

Fred
FredS
Posts: 98
Joined: Mon May 11, 2015 9:42 pm

Re: FogBugz submission now MIME in 4.0.14

Post by FredS »

..more on this:

Had some time, looks like this issue is from this change:

Code: Select all

Mode:  Differences, Ignoring Unimportant, Just Selection
Left file: D:\VCL\madCollection\madExcept\Sources\madExcept.pas
Right file: D:\My Projects\Source\madExcept\madExcept.pas
9209       if ForceUtf8 or IsTrueUnicodeString(fields[fields.Items[i1]]) or (PosStr('<', fields[fields.Items[i1]]) > 0) then begin 
<> 9192       if ForceUtf8 or IsTrueUnicodeString(fields[fields.Items[i1]]) then begin
------------------------------------------------------------------------
User that is Admin will have <admin> and for email the email is in between those brackets.
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: FogBugz submission now MIME in 4.0.14

Post by madshi »

Oh well. I implemented this change for HTTP uploading and didn't remember that FogBugz runs through the same code (Mantis and BugZilla don't!). Will be properly fixed in the next build. For now you can simply undo that specific change.

Thanks for analyzing the problem!
FredS
Posts: 98
Joined: Mon May 11, 2015 9:42 pm

Re: FogBugz submission now MIME in 4.0.14

Post by FredS »

madshi wrote:Oh well. I implemented this change for HTTP uploading and didn't remember that FogBugz runs through the same code (Mantis and BugZilla don't!).
OK, except I post to BugzScout like this:

Code: Select all

  fields.Add('ScoutUserName', 'AutoReporter');
  fields.Add('ScoutProject', 'Inbox');
  fields.Add('ScoutArea', ScoutArea);
  fields.Add('Description', Subject);
  fields.Add('Extra', bugReport);
  fields.Add('Email', exceptIntf.MailFrom);
  fields.Add('ForceNewBug', '0');  // Merge Bugz
  fields.Add('ScoutDefaultMessage', 'Your ' + SubmissionText[isSupport] + ' has been submitted.');
  fields.Add('FriendlyResponse', '1'); // HTML Response
  {!! Will Call MAPI/MAILTO if it fails}   // *Testing*=Exit(False);
  result := HttpUpload('https://nastybugz.fogbugz.com/ScoutSubmit.asp', True, 0, '', '', nil, fields);
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: FogBugz submission now MIME in 4.0.14

Post by madshi »

Ok, I see. I've been told that some HTTP servers don't like fields with "<" because such fields could contain script code. Because of that I've added that code which "encodes" strings which start with a "<" character. I suppose BugzScout does not automatically "decode" such strings? (I mean otherwise you would never have noticed the problem, I guess.)
FredS
Posts: 98
Joined: Mon May 11, 2015 9:42 pm

Re: FogBugz submission now MIME in 4.0.14

Post by FredS »

madshi wrote:Ok, I see. I've been told that some HTTP servers don't like fields with "<" because such fields could contain script code. Because of that I've added that code which "encodes" strings which start with a "<" character. I suppose BugzScout does not automatically "decode" such strings? (I mean otherwise you would never have noticed the problem, I guess.)
All I can tell you that when I tested with ForceUtf8=TRUE the submission fails with unable to read or something like that.
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: FogBugz submission now MIME in 4.0.14

Post by madshi »

Well, I suppose I could add a parameter to "HttpUpload" to disable encoding of "<" fields. Would that help?
FredS
Posts: 98
Joined: Mon May 11, 2015 9:42 pm

Re: FogBugz submission now MIME in 4.0.14

Post by FredS »

madshi wrote:Well, I suppose I could add a parameter to "HttpUpload" to disable encoding of "<" fields. Would that help?
Don't think that's the issue.
With some more testing this works:

Code: Select all

      if ForceUtf8 or IsTrueUnicodeString(fields[fields.Items[i1]]) or True {or (PosStr('<', fields[fields.Items[i1]]) > 0)} then begin
        charset := 'utf-8';
        encoding := '';//'base64';
        as1 := {Encode}(EncodeUtf8(fields[fields.Items[i1]]));
      end else begin
I looked at an HTML page FogBugz supplies for testing and it used charset utf-8, so the failure made no sense until I removed the encoding. No files can be uploaded to BugzScout so decoding appears not to exist for these submissions, nor should it.
FredS
Posts: 98
Joined: Mon May 11, 2015 9:42 pm

Re: FogBugz submission now MIME in 4.0.14

Post by FredS »

FredS wrote: No files can be uploaded to BugzScout so decoding appears not to exist for these submissions, nor should it.
And this works as well, just encoding needed to be removed:

Code: Select all

      if ForceUtf8 or IsTrueUnicodeString(fields[fields.Items[i1]]) or (PosStr('<', fields[fields.Items[i1]]) > 0) then begin
        charset := 'utf-8';
        encoding := '';//'base64';
        as1 := {Encode}(EncodeUtf8(fields[fields.Items[i1]]));
But fails if ForceUtf8=True because UnicodeToAnsi encodes again.
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: FogBugz submission now MIME in 4.0.14

Post by madshi »

I don't understand your syntax with "{encode}". This doesn't look like a typical Delphi language syntax to me?
FredS
Posts: 98
Joined: Mon May 11, 2015 9:42 pm

Re: FogBugz submission now MIME in 4.0.14

Post by FredS »

madshi wrote:I don't understand your syntax with "{encode}". This doesn't look like a typical Delphi language syntax to me?
I just commented out the Base64 Encoding for testing.
Anyhow, I have implemented my own using System.Net.HttpClient. No Base64 Encoding so all works.

Code: Select all

function DfxHttpUpload(const httpUrl: String; const fields: TStrings; HttpPostReply: PString = nil): Boolean;
var
  Response: IHTTPResponse;
  HttpClient: THTTPClient;
begin
  HttpClient := THTTPClient.Create;
  try
    Response := HttpClient.Post(httpUrl, fields, nil, TEncoding.UTF8);
    Result := Response.StatusCode = HTTP_STATUS_OK;
    if Result.Error.SetErrMessage(Response.StatusText) then Exit;
    if Assigned(HttpPostReply) then HttpPostReply^ := Response.ContentAsString(TEncoding.UTF8);
  finally
    HttpClient.Free;
  end;
end;
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: FogBugz submission now MIME in 4.0.14

Post by madshi »

So no need for me to change anything, anymore?
FredS
Posts: 98
Joined: Mon May 11, 2015 9:42 pm

Re: FogBugz submission now MIME in 4.0.14

Post by FredS »

madshi wrote:So no need for me to change anything, anymore?
Correct, BugzScout submissions are most likely the only type that don't require MIME.
Post Reply