Skip to content

Conversation

@miljance
Copy link
Contributor

@miljance miljance commented Oct 27, 2025

Summary

  • Allowing E-Document module to support any extension for an E-document. Currently *.xml for most of the services except for ZUGFeRD where PDF is used.
  • Each connector that does not use *.xml format should subscribe to OnAfterGetFileExtension and ship file extension back.
  • There is another Pull Request on ALApExtension for ZUGFeRD
  • Base for Managing PDF File Extension for ZUGFeRD ALAppExtensions#29341

Work Item(s)

Fixes #5220 and #5104

Fixes AB#611441

@miljance miljance requested a review from a team as a code owner October 27, 2025 16:25
@github-actions github-actions bot added AL: Apps (W1) Add-on apps for W1 From Fork Pull request is coming from a fork labels Oct 27, 2025
@miljance miljance requested a review from duichwer October 28, 2025 16:28
JesperSchulz
JesperSchulz previously approved these changes Oct 29, 2025
@JesperSchulz JesperSchulz added Integration GitHub request for Integration area Linked Issue is linked to a Azure Boards work item labels Oct 29, 2025
@github-actions github-actions bot added this to the Version 28.0 milestone Oct 29, 2025
@JesperSchulz
Copy link
Contributor

Looks like we've got another codecop issue: Possible overflow assigning 'Text' to 'Text[4]'.

@pri-kise
Copy link
Contributor

Looks like we've got another codecop issue: Possible overflow assigning 'Text' to 'Text[4]'.

@miljance the problem seems to be the parametere var AttachmentFileExtension: Text[4] of the CreateAttachmentsBlob.

I would refactor this procedure, to only return a AttachmentFileNameWithExtension with a Max Length of 250 (This is the maximium length in the BaseApp).

I had a similiar requirement in the past to trim a filename:

// This shortens the filename but keeps the file extension.
    procedure ShortenFileName(FileName: Text): Text[250]
    var
        FileManagement: Codeunit "File Management";
        MaxFileNameWithoutExtensionLength: Integer;
        Extension: Text;
        FileNameWithoutExtension: Text;
        FileNameWithFixedLength: Text[250];
    begin
        if StrLen(FileName) <= MaxStrLen(FileNameWithFixedLength) then begin
            FileNameWithFixedLength := CopyStr(FileName, 1, MaxStrLen(FileNameWithFixedLength));
            exit(FileNameWithFixedLength);
        end;
        FileNameWithoutExtension := FileManagement.GetFileNameWithoutExtension(FileName);
        Extension := FileManagement.GetExtension(FileName);
        MaxFileNameWithoutExtensionLength := MaxStrLen(FileNameWithFixedLength) - StrLen(Extension) - 1;
        FileNameWithFixedLength := CopyStr(FileNameWithoutExtension, 1, MaxFileNameWithoutExtensionLength) + '.' + Extension;
        exit(FileNameWithFixedLength);
    end;

@miljance miljance force-pushed the SendingPDFForEDocument branch 3 times, most recently from cde3758 to 8062f05 Compare October 30, 2025 11:23
@miljance miljance force-pushed the SendingPDFForEDocument branch from 8062f05 to 045a9c8 Compare October 30, 2025 11:24
@miljance
Copy link
Contributor Author

Looks like we've got another codecop issue: Possible overflow assigning 'Text' to 'Text[4]'.

@miljance the problem seems to be the parametere var AttachmentFileExtension: Text[4] of the CreateAttachmentsBlob.

I would refactor this procedure, to only return a AttachmentFileNameWithExtension with a Max Length of 250 (This is the maximium length in the BaseApp).

I had a similiar requirement in the past to trim a filename:

// This shortens the filename but keeps the file extension.
    procedure ShortenFileName(FileName: Text): Text[250]
    var
        FileManagement: Codeunit "File Management";
        MaxFileNameWithoutExtensionLength: Integer;
        Extension: Text;
        FileNameWithoutExtension: Text;
        FileNameWithFixedLength: Text[250];
    begin
        if StrLen(FileName) <= MaxStrLen(FileNameWithFixedLength) then begin
            FileNameWithFixedLength := CopyStr(FileName, 1, MaxStrLen(FileNameWithFixedLength));
            exit(FileNameWithFixedLength);
        end;
        FileNameWithoutExtension := FileManagement.GetFileNameWithoutExtension(FileName);
        Extension := FileManagement.GetExtension(FileName);
        MaxFileNameWithoutExtensionLength := MaxStrLen(FileNameWithFixedLength) - StrLen(Extension) - 1;
        FileNameWithFixedLength := CopyStr(FileNameWithoutExtension, 1, MaxFileNameWithoutExtensionLength) + '.' + Extension;
        exit(FileNameWithFixedLength);
    end;

The overflow comes from using Text[4] for AttachmentFileExtension in CreateAttachmentsBlob.
I applied a minimal fix that resolves the CodeCop warning without introducing broader changes.
File extensions can be longer than 4 chars (including dot).
While the suggested refactor is valid in order to make sure no long file names are created, it feels beyond the scope of this bugfix.

@djukicmilica or @JesperSchulz please let me know if you think it makes sense to deal with file name length limitation in the scope of this change.

@JesperSchulz
Copy link
Contributor

@miljance, let's keep focus and deal with the file name length limitation in a separate PR. Time to get this merged.

@JesperSchulz JesperSchulz reopened this Dec 1, 2025
@JesperSchulz JesperSchulz removed the request for review from duichwer December 1, 2025 16:28
@JesperSchulz JesperSchulz enabled auto-merge (squash) December 1, 2025 16:28
@JesperSchulz JesperSchulz merged commit 193320c into microsoft:main Dec 1, 2025
82 of 132 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1 From Fork Pull request is coming from a fork Integration GitHub request for Integration area Linked Issue is linked to a Azure Boards work item

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: ZUGFeRD - Sending E-Document in PDF format attached with .xml extension

5 participants