Summary
mip package installer raises ValueError: Unsupported protocol when processing relative paths containing ../ segments. While the mip specification and common usage in micropython-lib imply support for relative URL resolution, the current implementation of requests (or the underlying URL parser) in the Unix port appears to reject URLs containing directory traversal segments.
Environment
- MicroPython version: v1.28.0
- Port: Unix (GCC 15.2.0)
>>> import requests
>>> requests.__version__
'0.10.2'
>>> import mip
>>> mip.__version__
'0.4.2'
Reproduction
When a package.json file uses a relative path to reference a file outside the current directory, the mip installer performs a concatenation that results in a URL containing ../.
package.json:
{
"version": "0.1.0",
"urls": [
["file.py", "../subdir/file.py"]
]
}
Execution:
import mip
mip.install("https://raw.githubusercontent.com/owner/repo/branch/subdir/package.json")
Observed Result:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "mip/__init__.py", line 1, in install
...
File "requests/__init__.py", line 75, in request
ValueError: Unsupported protocol:
Real-world example
./micropython -c "import requests; requests.get('https://raw.githubusercontent.com/ballistics-lab/micropython-bclibc/installer/natmod/../src/tiny_bclibc.py')"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "requests/__init__.py", line 205, in get
File "requests/__init__.py", line 190, in request
File "requests/__init__.py", line 75, in request
ValueError: Unsupported protocol:
It still reachae with python3
python3 -c "import requests; p
rint(requests.get('https://raw.githubusercontent.c
om/ballistics-lab/micropython-bclibc/installer/nat
mod/../src/tiny_bclibc.py').ok)"
True
Urllib
python3 -c "import urllib.req
uest; print(urllib.request.urlopen('https://raw.gi
thubusercontent.com/ballistics-lab/micropython-bcl
ibc/installer/natmod/../src/tiny_bclibc.py').getco
de() == 200)"
True
The url still reachable with web browser: https://raw.githubusercontent.com/ballistics-lab/micropython-bclibc/installer/natmod/../src/tiny_bclibc.py
Additional Context
Standard mip behavior (as seen in micropython-lib/mip) relies on concatenating a base_url with relative paths defined in the JSON.
Previously, this mechanism handled relative paths correctly. For instance, packages that use standard relative referencing within the same directory tree or logically sound paths typically resolve without issues. An example of a valid relative URL resolution that is expected to work is:
Summary
mip package installer raises ValueError: Unsupported protocol when processing relative paths containing ../ segments. While the mip specification and common usage in micropython-lib imply support for relative URL resolution, the current implementation of requests (or the underlying URL parser) in the Unix port appears to reject URLs containing directory traversal segments.
Environment
Reproduction
When a package.json file uses a relative path to reference a file outside the current directory, the mip installer performs a concatenation that results in a URL containing ../.
package.json:
{ "version": "0.1.0", "urls": [ ["file.py", "../subdir/file.py"] ] }Execution:
Observed Result:
Real-world example
It still reachae with python3
Urllib
The url still reachable with web browser: https://raw.githubusercontent.com/ballistics-lab/micropython-bclibc/installer/natmod/../src/tiny_bclibc.py
Additional Context
Standard mip behavior (as seen in micropython-lib/mip) relies on concatenating a base_url with relative paths defined in the JSON.
Previously, this mechanism handled relative paths correctly. For instance, packages that use standard relative referencing within the same directory tree or logically sound paths typically resolve without issues. An example of a valid relative URL resolution that is expected to work is:
The current issue specifically triggers when the path contains ../ (e.g., ../src/file.py). It appears that the request validator now considers the presence of .. in a URL string as malformed or an unsupported protocol, breaking the core functionality of mip for packages that do not use a flat file structure.