joerghoh commented on code in PR #56: URL: https://github.com/apache/sling-org-apache-sling-engine/pull/56#discussion_r1965253133
########## src/main/java/org/apache/sling/engine/impl/XSSContentTypeHeader.java: ########## @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.sling.engine.impl; + +/** + * This enumeration defines states hold in a ThreadLocal to indicate a + * previously detected XSS violation. + */ +public enum XSSContentTypeHeader { Review Comment: I am not sure about the term "XSS" in this entire PR; because the problem is not XSS, but rather a change in the content-type header, which can lead to a XSS problem on the client. So maybe rename the enum in "ContentTypeHeaderChanged" with the values "UNSET", "VALUE_UNCHANGED" and "VALUE_CHANGED"? ########## src/main/java/org/apache/sling/engine/impl/SlingHttpServletResponseImpl.java: ########## @@ -345,8 +345,13 @@ public void setContentType(final String type) { * @return an optional message to log */ private Optional<String> checkContentTypeOverride(@Nullable String contentType) { + if (requestData.getSlingRequestProcessor().getXssContentTypeHeader() == XSSContentTypeHeader.VIOLATED) { + return Optional.empty(); Review Comment: I think that we need here a comment, why this method is returned here immediately. -- 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: dev-unsubscr...@sling.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org