mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 11:53:49 +07:00
[jupyter] merging HTTP handlers
... because `JupyterCefPathHandler` is not a true "path handler" and doesn't fit into `BuiltInWebServer` security model; decoupling makes `WebServerPathHandler` easier to refactor. Besides, it delegates to an instance of `JupyterCefHttpHandler` anyway and needs an anonymous object to access `HttpRequestHandler#sendData` - so merging simplifies both the code and the logic. (cherry picked from commit bd2122b0f2bbd2ae74da4dc2bdada6de1ccc3e1b) (cherry picked from commit 7f157366ebb72b7083149e2a8d3a74bb17786f40) IJ-CR-155171 GitOrigin-RevId: 8798ac40ef8abf9ed2e2994a28bd32b00ffed267
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5dd2eb64cf
commit
9c2cf149ef
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.notebooks.jupyter.core.jupyter.preview
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ abstract class JupyterCefHttpHandlerBase(private val absolutePathFiles: Collecti
|
||||
return true
|
||||
}
|
||||
|
||||
fun processInternalLibs(uri: String): ByteArray? {
|
||||
private fun processInternalLibs(uri: String): ByteArray? {
|
||||
try {
|
||||
val extension = FileUtilRt.getExtension(uri)
|
||||
// map files used for debugging
|
||||
@@ -103,22 +103,17 @@ abstract class JupyterCefHttpHandlerBase(private val absolutePathFiles: Collecti
|
||||
}
|
||||
}
|
||||
|
||||
private fun getFileFromUrl(fullUri: String): String? {
|
||||
if (fullUri in absolutePathFiles) {
|
||||
return fullUri
|
||||
protected fun getFileFromUrl(fullPath: String): String? {
|
||||
if (fullPath in absolutePathFiles) {
|
||||
return fullPath
|
||||
}
|
||||
if (!fullUri.startsWith(PATH_PREFIX)) {
|
||||
return null
|
||||
if (fullPath.startsWith(PATH_PREFIX)) {
|
||||
val uri = fullPath.replace("//", "/").substring(PATH_PREFIX.length).trimStart('/')
|
||||
if (uri.isNotEmpty() && ".." !in uri) {
|
||||
return uri
|
||||
}
|
||||
}
|
||||
val uri = fullUri.replace("//", "/").substring(PATH_PREFIX.length).trimStart('/')
|
||||
if (uri.isEmpty()) {
|
||||
return null
|
||||
}
|
||||
|
||||
if (".." in uri) {
|
||||
return null
|
||||
}
|
||||
return uri
|
||||
return null
|
||||
}
|
||||
|
||||
abstract val appName: String
|
||||
@@ -131,4 +126,4 @@ abstract class JupyterCefHttpHandlerBase(private val absolutePathFiles: Collecti
|
||||
val resource = getResource(this::class.java, "$appName/$file")
|
||||
return resource.readBytes()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user