volosied commented on code in PR #1137:
URL: https://github.com/apache/myfaces/pull/1137#discussion_r4565408518
##########
impl/src/test/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletFactoryPathValidationTest.java:
##########
@@ -83,10 +84,80 @@ public void testNonFaceletExtensionIsRejected() throws
Exception
InvalidFileException ex = Assertions.assertThrows(
InvalidFileException.class,
- () -> factory.resolveURL(facesContext, source,
"template.html"),
- "Expected InvalidFileException for a .html path");
+ () -> factory.resolveURL(facesContext, source,
"template.properties"),
+ "Expected InvalidFileException for a .properties path");
Assertions.assertEquals(InvalidFileException.Reason.INVALID_EXTENSION,
ex.getReason(),
"Rejection reason should be INVALID_EXTENSION");
}
+
+ /**
+ * With no source URL, a relative traversal path must still be rejected
(the guard must not
+ * fail open when {@code source == null}).
+ */
+ @Test
+ public void testRelativeTraversalWithNullSourceIsRejected() throws
Exception
+ {
+ setProjectStage(ProjectStage.Development);
+
+ java.io.IOException ex = Assertions.assertThrows(
+ java.io.IOException.class,
+ () -> getFactory().resolveURL(facesContext, null,
"../../etc/passwd.xhtml"));
+ System.out.println("null-source rejection: " + ex);
Review Comment:
fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]