Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d15db8a
Backport of CSP-related changes
jasondlee Sep 5, 2025
d890b5a
Have Claude sync to Faces API 5.0 and Mojarra master branches and catch
BalusC Apr 25, 2026
d6c7cb3
Sync Spec1590IT as well
BalusC Apr 25, 2026
de6c62d
Revert API changes and keep CSP impl-specific (with help of Claude)
BalusC Apr 25, 2026
46a1be8
Add missing backports from 4241c65 and 082789b with help of Claude;
BalusC Apr 25, 2026
3e498a4
Merge pull request #5606 from jasondlee/csp
BalusC Apr 25, 2026
54720bd
Merge #5606 from 4.0 into 4.1
BalusC Apr 25, 2026
146fe1e
Prepare release org.glassfish:mojarra-parent:4.0.16
mojarra-bot Apr 27, 2026
215b3fd
Prepare next development cycle for 4.0.17-SNAPSHOT
mojarra-bot Apr 27, 2026
8c499b5
Cherrypicked 32c4302f7 from 5.0: Fixed `ReferenceError: "mojarra" is not
BalusC Apr 27, 2026
8062aff
Merge pull request #5715 from eclipse-ee4j/4.0.16
BalusC Apr 27, 2026
902948b
Fixed `ReferenceError: "mojarra" is not defined` in corner case when
BalusC Jan 12, 2026
dee5ea9
Merge remote-tracking branch 'origin/4.0' into 4.1
BalusC Apr 27, 2026
7ee6f74
Fix #5606: Restore YUI Compressor because 4.0 TCK still uses HtmlUnit
BalusC Apr 28, 2026
790f631
Fix #5606: the h:commandLink script must be rendered AFTER end tag
BalusC Apr 28, 2026
61bb884
Fix #5606: shouldWriteIdAttribute should always be true for UICommand
BalusC Apr 28, 2026
846f274
Fix #5606: render="@all" must also run CSP scripts
BalusC Apr 28, 2026
09efd70
Fix #5606: this one is a real Mojarra bug which only surfaced after CSP
BalusC Apr 28, 2026
8700308
Fix #5606: Merge branch 'make_sure_csp_backport_passes_the_4.0_tck' into
BalusC Apr 28, 2026
8f535c1
Merge branch 'make_sure_csp_backport_passes_the_4.1_tck' into
BalusC Apr 28, 2026
04d82a8
Fix a couple of failing tests caused by change in doEval after CSP
BalusC Apr 28, 2026
bdd358e
Merge branch 'make_sure_csp_backport_passes_the_4.1_tck' into
BalusC Apr 28, 2026
16b1d64
Backport faces-uncompressed.js improvements done during 4.1
BalusC Apr 28, 2026
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
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
import jakarta.faces.component.Doctype;
import jakarta.faces.component.EditableValueHolder;
import jakarta.faces.component.UIComponent;
import jakarta.faces.component.UIForm;
import jakarta.faces.component.UIPanel;
import jakarta.faces.component.UIViewRoot;
import jakarta.faces.component.html.HtmlDoctype;
Expand Down Expand Up @@ -405,7 +406,7 @@ public void renderView(FacesContext ctx, UIViewRoot viewToRender) throws IOExcep
*
* Note if you flag a view as transient then we won't acquire the session as you are stating it does not need one.
*/
if (isServerStateSaving() && !viewToRender.isTransient()) {
if (!viewToRender.isTransient() && extContext.getSession(false) == null && isServerStateSaving() && hasForm(ctx, viewToRender)) {
getSession(ctx);
}

Expand Down Expand Up @@ -1841,6 +1842,25 @@ private HttpSession getSession(FacesContext context) {
return null;
}

/**
* @return true if the view contains at least one {@link UIForm}, in which case state will be written and a session
* is needed under server-side state saving.
*/
private static boolean hasForm(FacesContext context, UIViewRoot viewRoot) {
if (viewRoot == null || viewRoot.getChildCount() == 0) {
return false;
}
boolean[] found = { false };
viewRoot.visitTree(VisitContext.createVisitContext(context), (visitContext, target) -> {
if (target instanceof UIForm) {
found[0] = true;
return VisitResult.COMPLETE;
}
return VisitResult.ACCEPT;
});
return found[0];
}

/**
* Gets and if needed initializes the faceletFactory
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ public void processPartial(PhaseId phaseId) {
if (isRenderAll()) {
renderAll(ctx, viewRoot);
renderState(ctx);
renderEvalScripts(ctx);
doFlashPostPhaseActions(ctx);
writer.endDocument();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce
writer.endElement("span");
} else {
writer.endElement("a");

String target = (String) component.getAttributes().get("target");
if (target != null) {
target = target.trim();
} else {
target = "";
}
Collection<ClientBehaviorContext.Parameter> params = getBehaviorParameters(component);
RenderKitUtils.renderOnclickEventListener(context, component, params, target, true);
}
}

Expand Down Expand Up @@ -163,16 +172,6 @@ protected void renderAsActive(FacesContext context, UIComponent command) throws
// render the current value as link text.
writeValue(command, writer);
writer.flush();

String target = (String) command.getAttributes().get("target");
if (target != null) {
target = target.trim();
} else {
target = "";
}

Collection<ClientBehaviorContext.Parameter> params = getBehaviorParameters(command);
RenderKitUtils.renderOnclickEventListener(context, command, params, target, true);
}

// --------------------------------------------------------- Private Methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

import jakarta.faces.application.FacesMessage;
import jakarta.faces.component.NamingContainer;
import jakarta.faces.component.UICommand;
import jakarta.faces.component.UIComponent;
import jakarta.faces.component.UIInput;
import jakarta.faces.component.UIParameter;
Expand Down Expand Up @@ -602,13 +603,16 @@ protected boolean shouldWriteIdAttribute(UIComponent component) {
// By default we only write the id attribute if:
//
// - We have a non-auto-generated id, or...
// - We have client behaviors.
// - We have client behaviors, or...
// - The component is a UICommand (its CSP-style click listener is attached
// via mojarra.ael(clientId, ...) which needs the id on the rendered element).
//
// We assume that if client behaviors are present, they
// may need access to the id (AjaxBehavior certainly does).

String id;
return null != (id = component.getId()) && (!id.startsWith(UIViewRoot.UNIQUE_ID_PREFIX)
|| component instanceof UICommand
|| component instanceof ClientBehaviorHolder && !((ClientBehaviorHolder) component).getClientBehaviors().isEmpty());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,6 @@ if ( !( (window.faces && window.faces.specversion && window.faces.specversion >=
return inputElementName in form ? form[inputElementName] : getElementByName(form,inputElementName);
}

/**
* append a new pair of parameter=value to a query string
* @ignore
*/

/**
* return true if one of the dom elements contains
Expand Down Expand Up @@ -355,12 +351,13 @@ if ( !( (window.faces && window.faces.specversion && window.faces.specversion >=
};

/**
* Remove all the portion of code matching the script pattern from the passed string
* Remove all the portion of code matching the script pattern from the passed string,
* preserving scripts whose type is set to something other than text/javascript.
* @param html a String containing a portion of html
* @ignore
*/
const removeScripts = function removeScripts(html) {
return html.replace(SCRIPT_TAG_REGEX, function(match, content) {
return html.replace(SCRIPT_TAG_REGEX, (match) => {
const type = match.match(TAG_ATTRIBUTE_TYPE_REGEX);
if (!!type && type[1] !== "text/javascript") {
return match; // keep non-text/javascript scripts
Expand Down Expand Up @@ -3228,17 +3225,9 @@ mojarra.l = function l(l) {
if (document.readyState === "complete") {
setTimeout(l);
}
else if (window.addEventListener) {
window.addEventListener("load", l, false);
}
else if (typeof window.onload === "function") {
const oldListener = window.onload;
window.onload = function() { oldListener(); l(); };
}
else {
window.onload = l;
window.addEventListener("load", l);
}

};

/**
Expand Down
2 changes: 1 addition & 1 deletion impl/src/test/ts/spec/mojarra.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ describe("mojarra.l", () => {

(moj().l as Function)(callback);

expect(spy).toHaveBeenCalledWith("load", callback, false);
expect(spy).toHaveBeenCalledWith("load", callback);

spy.mockRestore();
if (originalReadyState) {
Expand Down
Loading