Stirling-Tools / Stirling-PDF

#1 Locally hosted web application that allows you to perform various operations on PDF files
https://stirlingpdf.com
MIT License
46.08k stars 3.75k forks source link

[Bug]: Markdown to PDF Conversion Allows Uploading of Non-Markdown Files #2218

Closed MaratheHarshad closed 1 day ago

MaratheHarshad commented 1 day ago

Installation Method

None

The Problem

Description:

Currently, the file input for the "Markdown to PDF" feature accepts all types of files, including non-Markdown files. To prevent errors and ensure the correct files are processed, the input should be restricted to only accept .md (Markdown) files.

Feature URL: https://stirlingpdf.io/markdown-to-pdf

Steps to Reproduce:

  1. Go to the "Markdown to PDF" feature page.
  2. Open the file input dialog.
  3. Notice that it accepts all types of files, including .pdf, .txt, .docx, etc.

Screenshots:

input error

Expected Behavior: The file input should only accept .md files for conversion, and any other file types should be rejected.

Suggested Solution: Modify the file input HTML to use accept=".md".

Version of Stirling-PDF

0.32.0

Last Working Version of Stirling-PDF

No response

Page Where the Problem Occurred

https://stirlingpdf.io/markdown-to-pdf

Docker Configuration

No response

Relevant Log Output

No response

Additional Information

No response

Browsers Affected

No response

No Duplicate of the Issue

dosubot[bot] commented 1 day ago

Hey there, @MaratheHarshad! I'm here to help you with any bugs, questions, or contributions. Let me know how I can assist you!

To address the issue of the "Markdown to PDF" feature accepting non-Markdown files, you can modify the HTML file input element to restrict it to only accept .md files. This can be done by setting the accept attribute to .md in the file input element. Here's how you can implement this change:

<div th:replace="~{fragments/common :: fileSelector(name='fileInput', multipleInputsForSingleRequest=false, accept='.md')}"></div>

This modification will ensure that the file input only allows files with the .md extension to be selected, preventing errors with non-Markdown files [1].

To continue talking to Dosu, mention @dosu.