View | Details | Raw Unified | Return to bug 40383
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt (-8 / +11 lines)
Lines 50-67 Link Here
50
    <script>
50
    <script>
51
        var interface = "[% interface | html %]";
51
        var interface = "[% interface | html %]";
52
        var theme = "[% theme | html %]";
52
        var theme = "[% theme | html %]";
53
        $(document).ready(function() {
53
    </script>
54
    <script>
55
        $(document).ready(function () {
54
            // Initialize enhanced EDIFACT display
56
            // Initialize enhanced EDIFACT display
55
            EdifactDisplay.init({
57
            EdifactDisplay.init({
56
                modalId: '#EDI_modal',
58
                modalId: "#EDI_modal",
57
                expandByDefault: true,
59
                expandByDefault: true,
58
                showElementDetails: false
60
                showElementDetails: false,
59
            });
61
            });
60
62
61
            // Get CSRF token once for reuse
63
            // Get CSRF token once for reuse
62
            var csrfToken = $('meta[name="csrf-token"]').attr("content") ? $('meta[name="csrf-token"]').attr("content").trim() : '';
64
            var csrfToken = $('meta[name="csrf-token"]').attr("content") ? $('meta[name="csrf-token"]').attr("content").trim() : "";
63
65
64
            var edi_msgs_table_url = '/api/v1/acquisitions/edifiles?';
66
            var edi_msgs_table_url = "/api/v1/acquisitions/edifiles?";
65
            var edi_msgs_table = $("#edi_msgs").kohaTable(
67
            var edi_msgs_table = $("#edi_msgs").kohaTable(
66
                {
68
                {
67
                    ajax: {
69
                    ajax: {
Lines 96-102 Link Here
96
                                    // JSON encode the errors instead of constructing HTML
98
                                    // JSON encode the errors instead of constructing HTML
97
                                    let errorsJson = JSON.stringify(row.errors);
99
                                    let errorsJson = JSON.stringify(row.errors);
98
                                    // Escape quotes for HTML attribute
100
                                    // Escape quotes for HTML attribute
99
                                    errorsJson = errorsJson.replace(/"/g, '&quot;');
101
                                    errorsJson = errorsJson.replace(/"/g, "&quot;");
100
                                    rendered = row.status + ' (<a href="#" data-bs-toggle="modal" data-bs-target="#EDI_errors_modal" data-bs-errors="' + errorsJson + '" data-bs-filename="' + row.filename + '">' + _("with errors") + "</a>)";
102
                                    rendered = row.status + ' (<a href="#" data-bs-toggle="modal" data-bs-target="#EDI_errors_modal" data-bs-errors="' + errorsJson + '" data-bs-filename="' + row.filename + '">' + _("with errors") + "</a>)";
101
                                } else {
103
                                } else {
102
                                    rendered = row.status;
104
                                    rendered = row.status;
Lines 160-169 Link Here
160
162
161
                                // Import button
163
                                // Import button
162
                                if (row.status == "new") {
164
                                if (row.status == "new") {
163
                                    result += '<a class="btn btn-default btn-xs import_msg" href="/cgi-bin/koha/acqui/edifactmsgs.pl?op=import&amp;message_id=' + encodeURIComponent(row.id) + '"><i class="fa fa-cog"></i> ' + _("Import") + "</a>";
165
                                    result +=
166
                                        '<a class="btn btn-default btn-xs import_msg" href="/cgi-bin/koha/acqui/edifactmsgs.pl?op=import&amp;message_id=' + encodeURIComponent(row.id) + '"><i class="fa fa-cog"></i> ' + _("Import") + "</a>";
164
                                }
167
                                }
165
168
166
                                result += '</div>';
169
                                result += "</div>";
167
                                return result;
170
                                return result;
168
                            },
171
                            },
169
                        },
172
                        },
(-)a/koha-tmpl/intranet-tmpl/prog/js/modals/edifact_errors.js (-16 / +4 lines)
Lines 57-63 const EdifactErrorsDisplay = (() => { Link Here
57
            } catch (e) {
57
            } catch (e) {
58
                console.error("Error parsing errors JSON:", e);
58
                console.error("Error parsing errors JSON:", e);
59
                modalBody.html(
59
                modalBody.html(
60
                    `<div class="alert alert-danger">Error loading error details: ${escapeHtml(e.message)}</div>`
60
                    `<div class="alert alert-danger">Error loading error details: ${e.message.escapeHtml()}</div>`
61
                );
61
                );
62
            }
62
            }
63
        } else {
63
        } else {
Lines 76-94 const EdifactErrorsDisplay = (() => { Link Here
76
            .map(
76
            .map(
77
                error => `
77
                error => `
78
            <li class="list-group-item list-group-item-danger">
78
            <li class="list-group-item list-group-item-danger">
79
                <strong>Error:</strong> ${escapeHtml(error.details || "Unknown error")}
79
                <strong>Error:</strong> ${(error.details || "Unknown error").escapeHtml()}
80
                ${
80
                ${
81
                    error.section
81
                    error.section
82
                        ? `
82
                        ? `
83
                    <br><small><strong>Section:</strong></small>
83
                    <br><small><strong>Section:</strong></small>
84
                    <pre class="mt-1 mb-0" style="font-size: 0.85em; background-color: #f8f9fa; padding: 0.5rem; border-radius: 0.25rem;">${escapeHtml(error.section)}</pre>
84
                    <pre class="mt-1 mb-0" style="font-size: 0.85em; background-color: #f8f9fa; padding: 0.5rem; border-radius: 0.25rem;">${error.section.escapeHtml()}</pre>
85
                `
85
                `
86
                        : ""
86
                        : ""
87
                }
87
                }
88
                ${
88
                ${
89
                    error.date
89
                    error.date
90
                        ? `
90
                        ? `
91
                    <br><small class="text-muted"><strong>Date:</strong> ${escapeHtml(error.date)}</small>
91
                    <br><small class="text-muted"><strong>Date:</strong> ${error.date.escapeHtml()}</small>
92
                `
92
                `
93
                        : ""
93
                        : ""
94
                }
94
                }
Lines 113-130 const EdifactErrorsDisplay = (() => { Link Here
113
        filenameSpan.text("");
113
        filenameSpan.text("");
114
    };
114
    };
115
115
116
    const escapeHtml = str => {
117
        if (!str) return "";
118
        const escapeMap = {
119
            "&": "&amp;",
120
            "<": "&lt;",
121
            ">": "&gt;",
122
            '"': "&quot;",
123
            "'": "&#039;",
124
        };
125
        return str.replace(/[&<>"']/g, match => escapeMap[match]);
126
    };
127
128
    return { init };
116
    return { init };
129
})();
117
})();
130
118
(-)a/koha-tmpl/intranet-tmpl/prog/js/modals/edifact_interchange.js (-17 / +4 lines)
Lines 205-211 const EdifactDisplay = (() => { Link Here
205
                const tag = segment.tag || "";
205
                const tag = segment.tag || "";
206
                const content = (segment.raw || "").substring(tag.length);
206
                const content = (segment.raw || "").substring(tag.length);
207
                lines.push(
207
                lines.push(
208
                    `<div class="segment-line${focusClass}"${messageAttr}><span class="segment-tag">${escapeHtml(tag)}</span>${escapeHtml(content)}</div>`
208
                    `<div class="segment-line${focusClass}"${messageAttr}><span class="segment-tag">${tag.escapeHtml()}</span>${content.escapeHtml()}</div>`
209
                );
209
                );
210
            });
210
            });
211
211
Lines 935-948 const EdifactDisplay = (() => { Link Here
935
            if (boldTag && content && content.length >= 3) {
935
            if (boldTag && content && content.length >= 3) {
936
                const tag = content.substring(0, 3);
936
                const tag = content.substring(0, 3);
937
                const rest = content.substring(3);
937
                const rest = content.substring(3);
938
                div.innerHTML = `<i class="fa fa-chevron-down me-1"></i> <span class="segment-tag">${escapeHtml(tag)}</span>${escapeHtml(rest)}`;
938
                div.innerHTML = `<i class="fa fa-chevron-down me-1"></i> <span class="segment-tag">${tag.escapeHtml()}</span>${rest.escapeHtml()}`;
939
            } else {
939
            } else {
940
                div.innerHTML = `<i class="fa fa-chevron-down me-1"></i> ${escapeHtml(content)}`;
940
                div.innerHTML = `<i class="fa fa-chevron-down me-1"></i> ${content.escapeHtml()}`;
941
            }
941
            }
942
        } else if (boldTag && content && content.length >= 3) {
942
        } else if (boldTag && content && content.length >= 3) {
943
            const tag = content.substring(0, 3);
943
            const tag = content.substring(0, 3);
944
            const rest = content.substring(3);
944
            const rest = content.substring(3);
945
            div.innerHTML = `<span class="segment-tag">${escapeHtml(tag)}</span>${escapeHtml(rest)}`;
945
            div.innerHTML = `<span class="segment-tag">${tag.escapeHtml()}</span>${rest.escapeHtml()}`;
946
        } else {
946
        } else {
947
            div.textContent = content;
947
            div.textContent = content;
948
        }
948
        }
Lines 1004-1021 const EdifactDisplay = (() => { Link Here
1004
        });
1004
        });
1005
    };
1005
    };
1006
1006
1007
    const escapeHtml = str => {
1008
        if (!str) return "";
1009
        const escapeMap = {
1010
            "&": "&amp;",
1011
            "<": "&lt;",
1012
            ">": "&gt;",
1013
            '"': "&quot;",
1014
            "'": "&#039;",
1015
        };
1016
        return str.replace(/[&<>"']/g, match => escapeMap[match]);
1017
    };
1018
1019
    return {
1007
    return {
1020
        init,
1008
        init,
1021
        showMessage,
1009
        showMessage,
1022
- 

Return to bug 40383