Skip to content

AttachmentPublisher.getAttachmentPath does not taking care about to use only allowed file system characters #201

Description

@b8rni

Jenkins and plugins versions report

junit-attachments-plugin version: 330.v25180b_263160

What Operating System are you using (both controller, and any agents involved in the problem)?

Windows for controller and agents.

Reproduction steps

In AttachmentPublisher.getAttachmentPath the TestObject.safe method will be used to replace unsafe url characters:

Image

There are two problems with that:

  1. Not all unsafe URL characters are actually replaced by that method, as I reported here
  2. Even all unsafe URL characters are replaced, this does not mean that this is then also a valid file path. For example: while an "*" is valid to use in an URL, it is not allowed to use it in a windows file name. Even if all unsafe URL characters are replaced, this does not mean that the result is a valid file path. For example, while "*" is a valid character in a URL, it is not allowed in a Windows file name. When I try to enter "*" as a file name, I get the following pop-up:
Image

Expected Results

All not allowed characters should be replaced (operating system dependent)

Actual Results

Not all not allowed characters are replaced which leads to errors while parsing the test results.

Here is an example where we use parameterized tests that use invalid file path characters:
AttachmentsTests.cs

Image

The related test report:
TestResults.xml

And finally the error when trying to add the results via
junit keepProperties: true, skipPublishingChecks: true, stdioRetention: 'ALL', testDataPublishers: [attachments()], testResults: '*.xml'
in jenkins:
Image

When the test cases "*" and "|" of Can_Use_Invalid_File_Path_Signs_In_TestParameter will be removed, everything is fine.

Anything else?

The provided sample is just for demonstrating the problem.

In real life we use tools like Bogus for generating fake data (to simulate user input and so on). This means any UTF‑8 character can be generated, and in our case, it is completely valid to have such characters appear in a test parameter.

Are you interested in contributing a fix?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions