Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions core/src/main/resources/lib/layout/layout.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ THE SOFTWARE.
<link rel="apple-touch-icon" href="${resURL}/apple-touch-icon.png" sizes="180x180" />
<link rel="mask-icon" href="${resURL}/mask-icon.svg" color="#191717" />

<!-- CSRF Crumb meta tags for JavaScript access - Fix for JENKINS-76241 -->
<j:if test="${h.getCrumbRequestField() != null}">
<meta name="jenkins-crumb-field" content="${h.getCrumbRequestField()}" />
<meta name="jenkins-crumb-value" content="${h.getCrumb(request2)}" />
</j:if>

<script src="${resURL}/scripts/behavior.js" type="text/javascript"/>

<st:adjunct includes="org.kohsuke.stapler.bind"/>
Expand Down
2 changes: 1 addition & 1 deletion war/src/main/webapp/css/responsive-grid.css
Original file line number Diff line number Diff line change
Expand Up @@ -1815,4 +1815,4 @@
}
@-ms-viewport {
width: device-width;
}
}
57 changes: 57 additions & 0 deletions war/src/main/webapp/scripts/hudson-behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -2709,3 +2709,60 @@ var layoutUpdateCallback = {
}
},
};

/**
* Fix for JENKINS-76241: Prevent POST race condition
* Apply Behaviour rules early - MINIMAL, SAFE VERSION
*/
(function () {
"use strict";

if (window._jenkinsPostHandlerFixApplied) {
return;
}
window._jenkinsPostHandlerFixApplied = true;

// Just apply Behaviour earlier - THAT'S IT
function applyEarly() {
if (typeof Behaviour !== "undefined" && Behaviour.apply) {
try {
Behaviour.apply();
} catch (e) {
// Ignore - will retry on DOMContentLoaded
}
}
}

// Apply immediately
applyEarly();

// Apply on DOMContentLoaded as backup
document.addEventListener("DOMContentLoaded", applyEarly);

// Watch for new content
if (typeof MutationObserver !== "undefined") {
var observer = new MutationObserver(function (mutations) {
var needsReapply = false;
mutations.forEach(function (mutation) {
mutation.addedNodes.forEach(function (node) {
if (
node.nodeType === 1 &&
(node.tagName === "FORM" ||
(node.querySelector && node.querySelector("FORM")))
) {
needsReapply = true;
}
});
});
if (needsReapply) {
applyEarly();
}
});

document.addEventListener("DOMContentLoaded", function () {
if (document.body) {
observer.observe(document.body, { childList: true, subtree: true });
}
});
}
})();