Skip to content

Commit

Permalink
fix(url-encoding): fix regression in url encodingg
Browse files Browse the repository at this point in the history
  • Loading branch information
david-leifker committed Feb 12, 2025
1 parent 60bbedf commit 208d239
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import com.linkedin.metadata.spring.YamlPropertySourceFactory;
import java.lang.management.ManagementFactory;
import java.util.Set;
import javax.management.MBeanServer;
import org.eclipse.jetty.ee10.servlet.ServletHandler;
import org.eclipse.jetty.http.UriCompliance;
import org.eclipse.jetty.jmx.MBeanContainer;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.HttpConfiguration;
Expand Down Expand Up @@ -65,13 +68,27 @@ public class CommonApplicationConfig {
@Bean
public WebServerFactoryCustomizer<JettyServletWebServerFactory> jettyCustomizer() {
return factory -> {

// Configure HTTP
factory.addServerCustomizers(
server -> {

// HTTP Configuration
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setRequestHeaderSize(32768);

// See https://github.com/jetty/jetty.project/issues/11890
// Configure URI compliance to allow encoded slashes
httpConfig.setUriCompliance(
UriCompliance.from(
Set.of(
UriCompliance.Violation.AMBIGUOUS_PATH_SEPARATOR,
UriCompliance.Violation.AMBIGUOUS_PATH_ENCODING)));
// set this for Servlet 6+
server
.getContainedBeans(ServletHandler.class)
.forEach(handler -> handler.setDecodeAmbiguousURIs(true));

// HTTP Connector
ServerConnector connector =
new ServerConnector(server, new HttpConnectionFactory(httpConfig));
Expand Down
98 changes: 98 additions & 0 deletions smoke-test/tests/openapi/v3/entities.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
"method": "delete"
}
},
{
"request": {
"url": "/openapi/v3/entity/dataset/urn%3Ali%3Adataset%3A%28urn%3Ali%3AdataPlatform%3Atest%2Cdataset%2FEntityV3%2CPROD%29",
"description": "Remove test dataset with %2F",
"method": "delete"
}
},
{
"request": {
"url": "/openapi/v3/entity/dataset",
Expand Down Expand Up @@ -156,5 +163,96 @@
]
}
}
},
{
"request": {
"url": "/openapi/v3/entity/dataset",
"params": {
"async": "false"
},
"description": "Create dataset with %2F",
"json": [
{
"urn": "urn:li:dataset:(urn:li:dataPlatform:test,dataset/EntityV3,PROD)",
"datasetProperties": {
"value": {
"name": "dataset/EntityV3",
"qualifiedName": "entities.dataset/EntityV3",
"customProperties": {},
"tags": []
}
},
"status": {
"value": {
"removed": false
}
}
}
]
}
},
{
"request": {
"url": "/openapi/v3/entity/dataset/urn%3Ali%3Adataset%3A%28urn%3Ali%3AdataPlatform%3Atest%2Cdataset%2FEntityV3%2CPROD%29",
"method": "get",
"description": "Get dataset with %2F",
"json": [
{
"urn": "urn:li:dataset:(urn:li:dataPlatform:test,dataset/EntityV3,PROD)",
"datasetProperties": {
"value": {
"name": "dataset/EntityV3",
"qualifiedName": "entities.dataset/EntityV3",
"customProperties": {},
"tags": []
}
},
"status": {
"value": {
"removed": false
}
}
}
]
},
"response": {
"json": {
"urn": "urn:li:dataset:(urn:li:dataPlatform:test,dataset/EntityV3,PROD)",
"browsePathsV2": {
"value": {
"path": [
{
"id": "Default"
}
]
}
},
"datasetKey": {
"value": {
"name": "dataset/EntityV3",
"platform": "urn:li:dataPlatform:test",
"origin": "PROD"
}
},
"dataPlatformInstance": {
"value": {
"platform": "urn:li:dataPlatform:test"
}
},
"datasetProperties": {
"value": {
"name": "dataset/EntityV3",
"customProperties": {},
"qualifiedName": "entities.dataset/EntityV3",
"tags": []
}
},
"status": {
"value": {
"removed": false
}
}
}
}
}
]

0 comments on commit 208d239

Please sign in to comment.