You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by sc...@apache.org on 2023/10/19 01:46:23 UTC
[tomcat] branch 8.5.x updated (c104daa372 -> a1b54130f2)
This is an automated email from the ASF dual-hosted git repository.
schultz pushed a change to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
from c104daa372 Use the proper API name
new a76a6d5368 Add changelog entry.
new 356db9f871 Attribution
new 9763186dbe Fail faster if a file does not exist.
new a1b54130f2 Add a "chomp" capability to optionally remove a trailing newline from a file-based value.
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../digester/ServiceBindingPropertySource.java | 39 +++++++++++++++++++++-
webapps/docs/changelog.xml | 4 +++
2 files changed, 42 insertions(+), 1 deletion(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[tomcat] 03/04: Fail faster if a file does not exist.
Posted by sc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
schultz pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 9763186dbeea80d58842f8eaac7b2b2660bc7420
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Wed Oct 18 21:31:05 2023 -0400
Fail faster if a file does not exist.
---
.../apache/tomcat/util/digester/ServiceBindingPropertySource.java | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/java/org/apache/tomcat/util/digester/ServiceBindingPropertySource.java b/java/org/apache/tomcat/util/digester/ServiceBindingPropertySource.java
index c6b7b6ae12..fd882fcf63 100644
--- a/java/org/apache/tomcat/util/digester/ServiceBindingPropertySource.java
+++ b/java/org/apache/tomcat/util/digester/ServiceBindingPropertySource.java
@@ -105,6 +105,11 @@ public class ServiceBindingPropertySource implements IntrospectionUtils.SecurePr
}
Path path = Paths.get(serviceBindingRoot, parts[0], parts[1]);
+
+ if (!path.toFile().exists()) {
+ return null;
+ }
+
try {
if (classLoader instanceof PermissionCheck) {
Permission p = new FilePermission(path.toString(), "read");
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[tomcat] 02/04: Attribution
Posted by sc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
schultz pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 356db9f871c2bd6928b7a9627ca4052b8fb559b9
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Wed Oct 18 21:40:23 2023 -0400
Attribution
---
webapps/docs/changelog.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index e524b92f5b..04a45d6980 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -118,7 +118,7 @@
</update>
<update>
Optionally allow ServiceBindingPropertySource to trim a trailing newline
- from a file containing a property-value.
+ from a file containing a property-value. (schultz)
</update>
</changelog>
</subsection>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[tomcat] 04/04: Add a "chomp" capability to optionally remove a trailing newline from a file-based value.
Posted by sc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
schultz pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit a1b54130f240c5daf68518d2682d636d6efde2ed
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Wed Oct 18 21:31:50 2023 -0400
Add a "chomp" capability to optionally remove a trailing newline from a file-based value.
---
.../digester/ServiceBindingPropertySource.java | 34 +++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/java/org/apache/tomcat/util/digester/ServiceBindingPropertySource.java b/java/org/apache/tomcat/util/digester/ServiceBindingPropertySource.java
index fd882fcf63..a96e5d8285 100644
--- a/java/org/apache/tomcat/util/digester/ServiceBindingPropertySource.java
+++ b/java/org/apache/tomcat/util/digester/ServiceBindingPropertySource.java
@@ -42,6 +42,7 @@ import org.apache.tomcat.util.security.PermissionCheck;
* /keyFile
* /file
* /chainFile
+ * /keyPassword
* </pre>
* <pre>
* {@code
@@ -49,10 +50,19 @@ import org.apache.tomcat.util.security.PermissionCheck;
* <Certificate certificateKeyFile="${custom-certificate.keyFile}"
* certificateFile="${custom-certificate.file}"
* certificateChainFile="${custom-certificate.chainFile}"
+ * certificateKeyPassword="${chomp:custom-certificate.keyPassword}"
* type="RSA" />
* </SSLHostConfig> }
* </pre>
*
+ * <p>
+ * The optional <code>chomp:</code> prefix will cause the ServiceBindingPropertySource
+ * to trim a single newline (<code>\r\n</code>, <code>\r</code>, or <code>\n</code>)
+ * from the end of the file, if it exists. This is a convenience for hand-edited
+ * files/values where removing a trailing newline is difficult, and trailing
+ * whitespace changes the meaning of the value.
+ * </p>
+ *
* How to configure:
* <pre>
* {@code
@@ -98,6 +108,12 @@ public class ServiceBindingPropertySource implements IntrospectionUtils.SecurePr
return null;
}
+ boolean chomp = false;
+ if (key.startsWith("chomp:")) {
+ chomp = true;
+ key = key.substring(6); // Remove the "chomp:" prefix
+ }
+
// we expect the keys to be in the format $SERVICE_BINDING_ROOT/<binding-name>/<key>
String[] parts = key.split("\\.");
if (parts.length != 2) {
@@ -117,7 +133,23 @@ public class ServiceBindingPropertySource implements IntrospectionUtils.SecurePr
return null;
}
}
- return new String(Files.readAllBytes(path));
+
+ byte[] bytes = Files.readAllBytes(path);
+
+ int length = bytes.length;
+
+ if (chomp) {
+ if(length > 1 && bytes[length - 2] == '\r' && bytes[length - 2] == '\n') {
+ length -= 2;
+ } else if (length > 0) {
+ byte c = bytes[length - 1];
+ if (c == '\r' || c == '\n') {
+ length -= 1;
+ }
+ }
+ }
+
+ return new String(bytes, 0, length);
} catch (IOException e) {
return null;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[tomcat] 01/04: Add changelog entry.
Posted by sc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
schultz pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit a76a6d536877fc1e18c64fa07628fc31851829bf
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Wed Oct 18 21:39:51 2023 -0400
Add changelog entry.
---
webapps/docs/changelog.xml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index fe075b3259..e524b92f5b 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -116,6 +116,10 @@
statistics as JSON, using the <code>JSON=true</code> URL parameter.
(remm)
</update>
+ <update>
+ Optionally allow ServiceBindingPropertySource to trim a trailing newline
+ from a file containing a property-value.
+ </update>
</changelog>
</subsection>
<subsection name="Other">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org