solara-ui 1.35.0__py2.py3-none-any.whl → 1.35.1__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
solara/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """Build webapps using IPywidgets"""
2
2
 
3
- __version__ = "1.35.0"
3
+ __version__ = "1.35.1"
4
4
  github_url = "https://github.com/widgetti/solara"
5
5
  git_branch = "master"
6
6
 
solara/__main__.py CHANGED
@@ -653,7 +653,7 @@ def markdown(target: typing.Optional[Path] = None):
653
653
 
654
654
 
655
655
  def write_script(name: str, target: typing.Optional[Path]):
656
- code = (HERE / "template" / f"{name}.py").read_text()
656
+ code = (HERE / "template" / f"{name}.py").read_text(encoding="utf-8")
657
657
  if target is None:
658
658
  target = Path("sol.py")
659
659
  else:
solara/autorouting.py CHANGED
@@ -215,11 +215,9 @@ def RenderPage(main_name: str = "Page"):
215
215
  solara.Button(
216
216
  icon_name="mdi-pencil", icon=True, href=url, target="_blank", style={"position": "absolute", "top": "0px", "right": "0px"}
217
217
  )
218
- # solara.Markdown(path.read_text(), unsafe_solara_execute=True)
219
- component(path.read_text(), unsafe_solara_execute=True)
218
+ component(path.read_text(encoding="utf-8"), unsafe_solara_execute=True)
220
219
  else:
221
- # content = solara.Markdown(path.read_text(), unsafe_solara_execute=True)
222
- content = component(path.read_text(), unsafe_solara_execute=True)
220
+ content = component(path.read_text(encoding="utf-8"), unsafe_solara_execute=True)
223
221
 
224
222
  main = solara.Div(
225
223
  classes=["solara-autorouter-content"],
@@ -52,7 +52,7 @@ def Style(value: Union[str, Path] = ""):
52
52
  try:
53
53
  async for _ in watchfiles.awatch(value):
54
54
  print(value, "changed, reloading css") # noqa
55
- set_css_content_reloaded(cast(Path, value).read_text())
55
+ set_css_content_reloaded(cast(Path, value).read_text(encoding="utf-8"))
56
56
  except RuntimeError:
57
57
  pass # swallow the RuntimeError: Already borrowed errors from watchfiles
58
58
  except Exception:
@@ -70,7 +70,7 @@ def Style(value: Union[str, Path] = ""):
70
70
  if css_content_reloaded is not None:
71
71
  css_content = css_content_reloaded
72
72
  else:
73
- css_content = value.read_text() if isinstance(value, Path) else value
73
+ css_content = value.read_text(encoding="utf-8") if isinstance(value, Path) else value
74
74
  # del value
75
75
  hash = hashlib.sha256(css_content.encode("utf-8")).hexdigest()
76
76
  # the key is unique for this component + value
solara/server/app.py CHANGED
@@ -229,7 +229,7 @@ class AppScript:
229
229
  path = Path(name)
230
230
  if path.suffix == ".vue":
231
231
  logger.info("Vue file changed: %s", name)
232
- template_content = path.read_text()
232
+ template_content = path.read_text(encoding="utf-8")
233
233
  for context in list(kernel_context.contexts.values()):
234
234
  with context:
235
235
  for filepath, widget in context.templates.items():
@@ -1,9 +1,9 @@
1
1
  import logging
2
- import os
3
2
  import pathlib
4
3
  import shutil
5
4
 
6
5
  import requests
6
+ from solara.server.utils import path_is_child_of
7
7
 
8
8
  import solara.settings
9
9
 
@@ -14,6 +14,9 @@ cdn_url_path = "_solara/cdn"
14
14
 
15
15
  def put_in_cache(base_cache_dir: pathlib.Path, path, data: bytes):
16
16
  cache_path = base_cache_dir / path
17
+ if not path_is_child_of(cache_path, base_cache_dir):
18
+ raise PermissionError("Trying to write outside of cache directory")
19
+
17
20
  pathlib.Path(cache_path.parent).mkdir(parents=True, exist_ok=True)
18
21
  try:
19
22
  logger.info("Writing cache file: %s", cache_path)
@@ -27,9 +30,7 @@ def get_from_cache(base_cache_dir: pathlib.Path, path):
27
30
  # Make sure cache_path is a subdirectory of base_cache_dir
28
31
  # so we don't accidentally read files from the parent directory
29
32
  # which is a security risk.
30
- # We use os.path.normpath() because we do not want to follow symlinks
31
- # in editable installs, since some packages are symlinked
32
- if not os.path.normpath(cache_path).startswith(str(base_cache_dir.resolve())):
33
+ if not path_is_child_of(cache_path, base_cache_dir):
33
34
  logger.warning("Trying to read from outside of cache directory: %s is not a subdir of %s", cache_path, base_cache_dir)
34
35
  raise PermissionError("Trying to read from outside of cache directory")
35
36
 
@@ -68,6 +69,9 @@ def get_path(base_cache_dir: pathlib.Path, path) -> pathlib.Path:
68
69
  store_path = path if len(parts) != 1 else pathlib.Path(path) / "__main.js"
69
70
  cache_path = base_cache_dir / store_path
70
71
 
72
+ if not path_is_child_of(cache_path, base_cache_dir):
73
+ raise PermissionError("Trying to read from outside of cache directory")
74
+
71
75
  if cache_path.exists():
72
76
  # before d7eba856f100d5c3c64f4eec22c62390f084cb40 on windows, we could
73
77
  # accidentally write to the cache directory, so we need to check if we still
solara/server/flask.py CHANGED
@@ -199,7 +199,7 @@ def nbext(dir, filename):
199
199
  for directory in server.nbextensions_directories:
200
200
  file = directory / dir / filename
201
201
  if file.exists():
202
- return send_from_directory(directory / dir, filename)
202
+ return send_from_directory(directory, dir + os.path.sep + filename)
203
203
  return flask.Response("not found", status=404)
204
204
 
205
205
 
@@ -217,7 +217,10 @@ if solara.settings.assets.proxy:
217
217
  if not allowed():
218
218
  abort(401)
219
219
  cache_directory = settings.assets.proxy_cache_dir
220
- content = cdn_helper.get_data(Path(cache_directory), path)
220
+ try:
221
+ content = cdn_helper.get_data(Path(cache_directory), path)
222
+ except PermissionError:
223
+ return flask.Response("not found", status=404)
221
224
  mime = mimetypes.guess_type(path)
222
225
  return flask.Response(content, mimetype=mime[0])
223
226
 
@@ -3,6 +3,7 @@ import json
3
3
  import logging
4
4
  import math
5
5
  import os
6
+ from pathlib import Path
6
7
  import sys
7
8
  import threading
8
9
  import typing
@@ -14,6 +15,8 @@ import starlette.websockets
14
15
  import uvicorn.server
15
16
  import websockets.legacy.http
16
17
 
18
+ from solara.server.utils import path_is_child_of
19
+
17
20
  try:
18
21
  import solara_enterprise
19
22
 
@@ -405,6 +408,9 @@ class StaticNbFiles(StaticFilesOptionalAuth):
405
408
  original_path = os.path.join(directory, path)
406
409
  full_path = os.path.realpath(original_path)
407
410
  directory = os.path.realpath(directory)
411
+ # return early if someone tries to access a file outside of the directory
412
+ if not path_is_child_of(Path(original_path), Path(directory)):
413
+ return "", None
408
414
  try:
409
415
  return full_path, os.stat(full_path)
410
416
  except (FileNotFoundError, NotADirectoryError):
@@ -449,7 +455,6 @@ class StaticCdn(StaticFilesOptionalAuth):
449
455
  full_path = str(get_path(settings.assets.proxy_cache_dir, path))
450
456
  except Exception:
451
457
  return "", None
452
-
453
458
  return full_path, os.stat(full_path)
454
459
 
455
460
 
@@ -119,7 +119,7 @@ async def main():
119
119
  ]
120
120
  for dep in requirements:
121
121
  await micropip.install(dep, keep_going=True)
122
- await micropip.install("/wheels/solara-1.35.0-py2.py3-none-any.whl", keep_going=True)
122
+ await micropip.install("/wheels/solara-1.35.1-py2.py3-none-any.whl", keep_going=True)
123
123
  import solara
124
124
 
125
125
  el = solara.Warning("lala")
solara/server/utils.py CHANGED
@@ -1,6 +1,7 @@
1
1
  import contextlib
2
2
  import logging
3
3
  import os
4
+ from pathlib import Path
4
5
  import pdb
5
6
  import traceback
6
7
 
@@ -16,6 +17,12 @@ def start_error(title, msg, exception: Exception = None):
16
17
  os._exit(-1)
17
18
 
18
19
 
20
+ def path_is_child_of(path: Path, parent: Path) -> bool:
21
+ # We use os.path.normpath() because we do not want to follow symlinks
22
+ # in editable installs, since some packages are symlinked
23
+ return os.path.normpath(path).startswith(os.path.normpath(parent))
24
+
25
+
19
26
  @contextlib.contextmanager
20
27
  def pdb_guard():
21
28
  from . import settings
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: solara-ui
3
- Version: 1.35.0
3
+ Version: 1.35.1
4
4
  Dynamic: Summary
5
5
  Project-URL: Home, https://www.github.com/widgetti/solara
6
6
  Project-URL: Documentation, https://solara.dev
@@ -1,9 +1,9 @@
1
1
  prefix/etc/jupyter/jupyter_notebook_config.d/solara.json,sha256=3UhTBQi6z7F7pPjmqXxfddv79c8VGR9H7zStDLp6AwY,115
2
2
  prefix/etc/jupyter/jupyter_server_config.d/solara.json,sha256=D9J-rYxAzyD5GOqWvuPjacGUVFHsYtTfZ4FUbRzRvIA,113
3
- solara/__init__.py,sha256=SDPK0vT6QxeWzzWF9qbyAr5f9oYiBkHmqlY1dPqwMVc,3584
4
- solara/__main__.py,sha256=_RSUhoxkTruY4MMlSJ9qBKWdsgNSasuYs1EBbufnNrM,23656
3
+ solara/__init__.py,sha256=G6n9833GZNikEicJ0sIt4c5k7tAso-pCAx19zVYHHk4,3584
4
+ solara/__main__.py,sha256=hxMYlUg-t-KTOJSVfEHwvcTV51WHX6INpN0F_qaesUg,23672
5
5
  solara/alias.py,sha256=9vfLzud77NP8in3OID9b5mmIO8NyrnFjN2_aE0lSb1k,216
6
- solara/autorouting.py,sha256=IXNqJBaKjniuQIHGq_LSqoWXec9qq34t2b6UEqj4YBE,22677
6
+ solara/autorouting.py,sha256=k0f5SpySGbhutF1KKCRQTCtkBKKCsYT8C6gB_pUXK10,22535
7
7
  solara/cache.py,sha256=rZEW_xVIj3vvajntsQDnaglniTQ90izkX8vOqe1mMvE,10500
8
8
  solara/checks.html,sha256=NZoefOKYpE6NHQJchi4WE5HkDG3xpJW0kY6TOAFHQtE,3304
9
9
  solara/checks.py,sha256=WtMzUM1HN127juk5fFV2jdsJ1qT5Ghg21wEZfiVfIFc,7563
@@ -68,7 +68,7 @@ solara/components/spinner-solara.vue,sha256=fH8AtwXUZf_YZnUj-1OWspcbVWc-mSbY2T5s
68
68
  solara/components/spinner.py,sha256=EGB9qL6WnNchaEc8RnjPk79jm5TV9v_7UoEoDZKikBM,586
69
69
  solara/components/sql_code.py,sha256=XUx91w_E7q6QzOPpY1NZVuCNPh6hPP6gPJLM7cMDYs4,1190
70
70
  solara/components/sql_code.vue,sha256=ogqWdIOm1OnTQJj_p2UhcFPO_biv1uMaYCOCXPBJ6AQ,3815
71
- solara/components/style.py,sha256=l2UAke1Js9IMAFP31k5T2-YDjo2WMbR104ZYvMpXUEs,3112
71
+ solara/components/style.py,sha256=8xv5xXkfiTyVP0oRRh1ONQn0oJ2k40yTomQFEgP0-3k,3144
72
72
  solara/components/switch.py,sha256=Vq6LgroaY3jx4PO2n1_08lqPL9g0MUZNsMPA4uqKr7I,2309
73
73
  solara/components/tab_navigation.py,sha256=xVlVx4GvLNNxeE53sGtRLkcQB3mzEWM_jTlXOnY3SEs,1047
74
74
  solara/components/title.py,sha256=2B-PDlWOoY1fHYRRXnP7vUmRioqEHM9WJ2qjF6zVFGQ,2120
@@ -101,11 +101,11 @@ solara/lab/utils/headers.py,sha256=RMo8JUdztRePrdNfYCX1QEhrfyF6ktodr4v6tIREKbs,2
101
101
  solara/scope/__init__.py,sha256=0sP3B6L4Aai0b6nadPtEETb8XqdGmSFKvQusNH0-yvY,2987
102
102
  solara/scope/types.py,sha256=HTf_wnkpkhhtGaeFsB690KBP623CUuqiMssd72-u9yg,1540
103
103
  solara/server/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
104
- solara/server/app.py,sha256=6cWds871ZTD-zT5H2p3ep0cXX9AqT2VnKk3kIEbek60,20336
105
- solara/server/cdn_helper.py,sha256=BvqxkA3jKi1fEZ5g3FZjphx2NY6PnoxnSCG9JK6zdBE,3101
104
+ solara/server/app.py,sha256=JWWr2UZLxJVRCahFZUBeMwSpUn9dyswzywDuvCUfWQU,20352
105
+ solara/server/cdn_helper.py,sha256=mjdDWL1jVed40rEagP9L5CfZwFB77yUKqcFg--u2eds,3250
106
106
  solara/server/esm.py,sha256=dX9pzTJQ6kd6qNHQgzC938O5LTowLhuATXO0Q1paz44,2951
107
107
  solara/server/fastapi.py,sha256=qVIHn0_Kxr6zWqcBWySu5nnJ6pNTSDqb4EHIh-cqH_8,93
108
- solara/server/flask.py,sha256=7VsZ12XouYJvlObZ-ZotL4aupXWQE7OsyghJynWr0wk,9027
108
+ solara/server/flask.py,sha256=v3TUqZMKzijnoB9fv3xipM-kPtLziyNAV6Wiw0DLh7w,9149
109
109
  solara/server/jupytertools.py,sha256=cYFIUjLX7n0uuEXqWVWvmV6sV7R_MNg8ZZlabQgw8vk,1320
110
110
  solara/server/kernel.py,sha256=3mwRRBw6BOcKLACL4fCUGgtI_RZ5KTSM1MlAtRlDbmA,11092
111
111
  solara/server/kernel_context.py,sha256=RrNVAkoev6u6LZBvDfG86zyVs7eDVUsrp_4Au_FLlgY,16718
@@ -114,10 +114,10 @@ solara/server/reload.py,sha256=BBH7QhrV1-e9RVyNE3uz1oPj1DagC3t_XSqGPNz0nJE,9747
114
114
  solara/server/server.py,sha256=fo-3o7L20kC6tb4_mLzoVI39dodRRuNIVuCCYBOF94k,16268
115
115
  solara/server/settings.py,sha256=8QpVW_hYe4QvSVvDMeobpUEFa_jjCAGrSKgCGzjZ3As,7340
116
116
  solara/server/shell.py,sha256=xKox0fvDxdcWleE8p2ffCkihvjLJsWn2FujMbgUjYn0,8677
117
- solara/server/starlette.py,sha256=8cVrYxkt2hm7RaO9E12wHAqabK_viLPSbgUUXA19fRA,23599
117
+ solara/server/starlette.py,sha256=zOyE5cdsE-JVvXuoKWv2nnkWHeUBVV3b6i9-3sK0utI,23866
118
118
  solara/server/telemetry.py,sha256=GPKGA5kCIqJb76wgxQ2_U2uV_s0r-1tKqv-GVxo5hs8,6038
119
119
  solara/server/threaded.py,sha256=k9k461md4MxEFX-RLit5RpVRPFlQNwr-qp5pprT8JB0,2347
120
- solara/server/utils.py,sha256=I_PaObYgXz--fw-5G_K_uwxfEVSPynQud8Pn-MHDR3c,648
120
+ solara/server/utils.py,sha256=qYoSi5adwNVdcUuGj6N7jQU9fpXYDuBpsPg7bAKOMUw,938
121
121
  solara/server/websocket.py,sha256=hUYw9TeVf4vHKL8TGG4RAZGLL7rmkt1INVq5qSYRWOo,1076
122
122
  solara/server/assets/custom.css,sha256=4p04-uxHTobfr6Xkvf1iOrYiks8NciWLT_EwHZSy6jw,15
123
123
  solara/server/assets/custom.js,sha256=YT-UUYzA5uI5-enmbIsrRhofY_IJAO-HanaMwiNUEos,16
@@ -135,7 +135,7 @@ solara/server/static/highlight-dark.css,sha256=gmC3pr3x2BqJgTswNoN6AkqfEhBk24hPF
135
135
  solara/server/static/highlight.css,sha256=k8ZdT5iwrGQ5tXTQHAXuxvZrSUq3kwCdEpy3mlFoZjs,2637
136
136
  solara/server/static/main-vuetify.js,sha256=-FLlUqclZdVhCXsqawzpxtQ9vpaDA6KQdwoDKJCr_AI,8926
137
137
  solara/server/static/main.js,sha256=mcx4JNQ4Lg4pNdUIqMoZos1mZyYFS48yd_JNFFJUqIE,5679
138
- solara/server/static/solara_bootstrap.py,sha256=zwGV7dvJYWueF5Kl6dGZ0ACt2xAAAgcLr4V_19iRBiU,3195
138
+ solara/server/static/solara_bootstrap.py,sha256=ajBPF2o78wx3hGHt4gPU-qBE0Zpo9cyo86xjocUbyAs,3195
139
139
  solara/server/static/sun.svg,sha256=jEKBAGCr7b9zNYv0VUb7lMWKjnU2dX69_Ye_DZWGXJI,6855
140
140
  solara/server/static/webworker.js,sha256=cjAFz7-SygStHJnYlJUlJs-gE_7YQeQ-WBDcmKYyjvo,1372
141
141
  solara/server/templates/index.html.j2,sha256=JXQo1M-STFHLBOFetgG7509cAq8xUP0VAEtYDzz35fY,31
@@ -434,9 +434,9 @@ solara/widgets/vue/gridlayout.vue,sha256=nFZJotdznqI9tUYZ1Elv9OLA0adazxvVZAggMHH
434
434
  solara/widgets/vue/html.vue,sha256=48K5rjp0AdJDeRV6F3nOHW3J0WXPeHn55r5pGClK2fU,112
435
435
  solara/widgets/vue/navigator.vue,sha256=SLrzBI0Eiys-7maXA4e8yyD13-O5b4AnCGE9wKuJDHE,3646
436
436
  solara/widgets/vue/vegalite.vue,sha256=E3dlfhR-Ol7nqQZN6wCZC_3Tz98CJW0i_EU39mj0XHw,3986
437
- solara_ui-1.35.0.data/data/etc/jupyter/jupyter_notebook_config.d/solara.json,sha256=3UhTBQi6z7F7pPjmqXxfddv79c8VGR9H7zStDLp6AwY,115
438
- solara_ui-1.35.0.data/data/etc/jupyter/jupyter_server_config.d/solara.json,sha256=D9J-rYxAzyD5GOqWvuPjacGUVFHsYtTfZ4FUbRzRvIA,113
439
- solara_ui-1.35.0.dist-info/METADATA,sha256=_-WkmPpHeaki7f02ZMmtIVuNdUW29OA8_H8mxpz3xYM,7284
440
- solara_ui-1.35.0.dist-info/WHEEL,sha256=L5_n4Kc1NmrSdVgbp6hdnwwVwBnoYOCnbHBRMD-qNJ4,105
441
- solara_ui-1.35.0.dist-info/licenses/LICENSE,sha256=fFJUz-CWzZ9nEc4QZKu44jMEoDr5fEW-SiqljKpD82E,1086
442
- solara_ui-1.35.0.dist-info/RECORD,,
437
+ solara_ui-1.35.1.data/data/etc/jupyter/jupyter_notebook_config.d/solara.json,sha256=3UhTBQi6z7F7pPjmqXxfddv79c8VGR9H7zStDLp6AwY,115
438
+ solara_ui-1.35.1.data/data/etc/jupyter/jupyter_server_config.d/solara.json,sha256=D9J-rYxAzyD5GOqWvuPjacGUVFHsYtTfZ4FUbRzRvIA,113
439
+ solara_ui-1.35.1.dist-info/METADATA,sha256=xmBLIN83y97Vi8K9zWbz4TWbMoT9tWcIAD6y8QGN9kc,7284
440
+ solara_ui-1.35.1.dist-info/WHEEL,sha256=L5_n4Kc1NmrSdVgbp6hdnwwVwBnoYOCnbHBRMD-qNJ4,105
441
+ solara_ui-1.35.1.dist-info/licenses/LICENSE,sha256=fFJUz-CWzZ9nEc4QZKu44jMEoDr5fEW-SiqljKpD82E,1086
442
+ solara_ui-1.35.1.dist-info/RECORD,,