Revert "fix: don't allow attaching an file invalid url"

This commit is contained in:
Ejaaz Khan 2025-05-14 10:48:46 +05:30 committed by GitHub
parent dc3ab2ee14
commit 4f08c34696
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 26 deletions

View file

@ -524,37 +524,14 @@ function upload_via_file_browser() {
library_file_name: selected_file.value,
});
}
async function validate_html_url(url) {
try {
let response = await fetch(url, { method: "HEAD" });
let contentType = response.headers.get("Content-Type");
if (contentType && contentType.includes("text/html")) {
return false;
}
} catch (error) {
console.log("Error fetching URL:", error);
}
return true;
}
async function upload_via_web_link() {
function upload_via_web_link() {
let file_url = web_link.value.url;
if (!file_url) {
frappe.msgprint(__("Invalid URL"));
close_dialog.value = true;
return Promise.reject();
}
file_url = decodeURI(file_url);
const is_valid = await validate_html_url(file_url);
if (!is_valid) {
frappe.msgprint(__("Invalid or unsupported URL"));
return Promise.reject();
}
close_dialog.value = true;
return upload_file({
file_url,

View file

@ -78,8 +78,7 @@ def get_context(context) -> PrintContext:
body = get_html(
doctype=frappe.form_dict.doctype, name=frappe.form_dict.name, print_format=print_format.name
)
if cint(frappe.form_dict.trigger_print):
body += trigger_print_script
body += trigger_print_script
else:
body = get_rendered_template(
doc,