Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipfs add doesn't work on files with "%" in the name #10536

Closed
3 tasks done
bjl73o opened this issue Oct 4, 2024 · 2 comments · Fixed by #10649
Closed
3 tasks done

ipfs add doesn't work on files with "%" in the name #10536

bjl73o opened this issue Oct 4, 2024 · 2 comments · Fixed by #10649
Assignees
Labels
kind/bug A bug in existing code (including security flaws) P0 Critical: Tackled by core team ASAP

Comments

@bjl73o
Copy link

bjl73o commented Oct 4, 2024

Checklist

Installation method

ipfs-desktop

Version

Kubo version: 0.30.0

Config

{
    "API": {
      "HTTPHeaders": {
        "Access-Control-Allow-Credentials": [
          "true"
        ],
        "Access-Control-Allow-Methods": [
          "OPTIONS",
          "GET",
          "POST"
        ],
        "Access-Control-Allow-Origin": [
          "*"
        ]
      }
    },
    "Addresses": {
      "API": "/ip4/127.0.0.1/tcp/5001",
      "Announce": [
        "/ip4/(redacted)/tcp/4001",
        "/ip4/(redacted)/udp/4002/webrtc-direct",
        "/ip4/(redacted)/udp/4002/quic-v1",
        "/ip4/(redacted)/udp/4002/quic-v1/webtransport"
      ],
      "AppendAnnounce": null,
      "Gateway": "/ip4/0.0.0.0/tcp/8080",
      "NoAnnounce": [
        "/ip4/10.0.0.0/ipcidr/8",
        "/ip4/100.64.0.0/ipcidr/10",
        "/ip4/169.254.0.0/ipcidr/16",
        "/ip4/172.16.0.0/ipcidr/12",
        "/ip4/192.0.0.0/ipcidr/24",
        "/ip4/192.0.2.0/ipcidr/24",
        "/ip4/192.168.0.0/ipcidr/16",
        "/ip4/198.18.0.0/ipcidr/15",
        "/ip4/198.51.100.0/ipcidr/24",
        "/ip4/203.0.113.0/ipcidr/24",
        "/ip4/240.0.0.0/ipcidr/4",
        "/ip6/100::/ipcidr/64",
        "/ip6/2001:2::/ipcidr/48",
        "/ip6/2001:db8::/ipcidr/32",
        "/ip6/fc00::/ipcidr/7",
        "/ip6/fe80::/ipcidr/10"
      ],
      "Swarm": [
        "/ip4/0.0.0.0/tcp/4001",
        "/ip6/::/tcp/4001",
        "/ip4/0.0.0.0/udp/4002/webrtc-direct",
        "/ip4/0.0.0.0/udp/4002/quic-v1",
        "/ip4/0.0.0.0/udp/4002/quic-v1/webtransport",
        "/ip6/::/udp/4002/webrtc-direct",
        "/ip6/::/udp/4002/quic-v1",
        "/ip6/::/udp/4002/quic-v1/webtransport"
      ]
    },
    "AutoNAT": {},
    "Bootstrap": [
      "/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
      "/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa",
      "/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
      "/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",
      "/ip4/(redacted)/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"
    ],
    "DNS": {
      "Resolvers": null
    },
    "Datastore": {
      "BloomFilterSize": 1048576,
      "GCPeriod": "30m",
      "HashOnRead": false,
      "Spec": {
        "mounts": [
          {
            "child": {
              "path": "blocks",
              "shardFunc": "/repo/flatfs/shard/v1/next-to-last/2",
              "sync": true,
              "type": "flatfs"
            },
            "mountpoint": "/blocks",
            "prefix": "flatfs.datastore",
            "type": "measure"
          },
          {
            "child": {
              "compression": "none",
              "path": "datastore",
              "type": "levelds"
            },
            "mountpoint": "/",
            "prefix": "leveldb.datastore",
            "type": "measure"
          }
        ],
        "type": "mount"
      },
      "StorageGCWatermark": 70,
      "StorageMax": "2000GB"
    },
    "Discovery": {
      "MDNS": {
        "Enabled": true
      }
    },
    "Experimental": {
      "FilestoreEnabled": false,
      "GraphsyncEnabled": false,
      "Libp2pStreamMounting": false,
      "P2pHttpProxy": false,
      "ShardingEnabled": false,
      "StrategicProviding": false,
      "UrlstoreEnabled": false
    },
    "ExperimentalLibp2pStreamMounting": false,
    "Gateway": {
      "APICommands": [],
      "HTTPHeaders": {
        "Access-Control-Allow-Methods": [
          "GET",
          "HEAD"
        ],
        "Access-Control-Allow-Origin": [
          "*"
        ]
      },
      "NoDNSLink": false,
      "NoFetch": false,
      "PathPrefixes": [],
      "PublicGateways": null,
      "RootRedirect": "",
      "Writable": false
    },
    "Identity": {
      "PeerID": "(redacted)"
    },
    "Internal": {},
    "Ipns": {
      "RecordLifetime": "",
      "RepublishPeriod": "",
      "ResolveCacheSize": 500
    },
    "Libp2pStreamMounting": false,
    "Migration": {
      "DownloadSources": null,
      "Keep": ""
    },
    "Mounts": {
      "FuseAllowOther": false,
      "IPFS": "/ipfs",
      "IPNS": "/ipns"
    },
    "Peering": {
      "Peers": [
        {
          "Addrs": [
            "/ip4/(redacted)/tcp/4001",
            "/ip4/(redacted)/udp/4001/quic-v1",
            "/ip4/(redacted)/udp/4001/quic-v1/webtransport"
          ],
          "ID": "(redacted)"
        }
      ]
    },
    "Pinning": {},
    "Plugins": {
      "Plugins": null
    },
    "Provider": {
      "Strategy": ""
    },
    "Pubsub": {
      "DisableSigning": false,
      "Router": ""
    },
    "Reprovider": {
      "Strategy": "pinned"
    },
    "Routing": {
      "AcceleratedDHTClient": true,
      "Methods": null,
      "Routers": null
    },
    "Swarm": {
      "AddrFilters": null,
      "ConnMgr": {},
      "DisableBandwidthMetrics": false,
      "DisableNatPortMap": false,
      "EnableAutoRelay": false,
      "EnableRelayHop": false,
      "RelayClient": {
        "Enabled": false
      },
      "RelayService": {
        "Enabled": true
      },
      "ResourceMgr": {
        "Enabled": false
      },
      "Transports": {
        "Multiplexers": {},
        "Network": {},
        "Security": {}
      }
    }
  }

Description

Create an empty folder
Create an empty file in that folder, and name it anything. Include % in the name.
Add the folder to Kubo with ipfs add -r path

added QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn path/100
added QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn path/100%
added QmSSYRtVFpWBEXCKKJbLv78ixGYXZhs5gX6rVdYjyhYgw4 path

Copy the folder CID from the terminal
Open the link containing % in the browser
Observe the error: 400 Bad Request
1

@bjl73o bjl73o added kind/bug A bug in existing code (including security flaws) need/triage Needs initial labeling and prioritization labels Oct 4, 2024
@bjl73o
Copy link
Author

bjl73o commented Oct 4, 2024

1

@gammazero gammazero self-assigned this Dec 30, 2024
gammazero added a commit to ipfs/boxo that referenced this issue Dec 30, 2024
When the original URl contains special characters, such as "%", the correcponding redirect URL must escape these characters.

Fixes ipfs/kubo#10536
gammazero added a commit to ipfs/boxo that referenced this issue Dec 30, 2024
When the original URl contains special characters, such as "%", the correcponding redirect URL must escape these characters.

Fixes ipfs/kubo#10536
@gammazero
Copy link
Contributor

Files with a percent in their name appear to work. Directories with a percent in their name do not work:

  • Dir name ending with '%': 400 Bad Request
  • Dir name with % between other chars: 404 Not Found

These are fixed by adding a trailing "/" to the link name in the generated web page.

gammazero added a commit to ipfs/boxo that referenced this issue Jan 2, 2025
Directories with a "%" in their name do not work correctly when using the link on the generated web page. Adding a trailing "/" to the link name of these subdirectories fixes this.

Fixes issue ipfs/kubo#10536
gammazero added a commit that referenced this issue Jan 2, 2025
Directories with a "%" in their name do not work correctly when using the link on the generated web page. Ubgrade to boxo version with the fix that adds a trailing "/" to the subdirectory names.

Closes #10536
gammazero added a commit to ipfs/boxo that referenced this issue Jan 2, 2025
Directories with a "%" in their name do not work correctly when when redirected to a URL with a trailing slash. When the original URl contains special characters, such as "%", the correcponding redirect URL must escape these characters.

Fixes issue ipfs/kubo#10536
gammazero added a commit that referenced this issue Jan 2, 2025
When a director gets redirected to a URL with a treailing slash, special chars in the directory name must be escaped in the redirect URL. This upgrades to a version of box that has that fix.

Closes #10536
gammazero added a commit that referenced this issue Jan 2, 2025
When a director gets redirected to a URL with a treailing slash, special chars in the directory name must be escaped in the redirect URL. This upgrades to a version of box that has that fix.

Closes #10536
@gammazero gammazero added P0 Critical: Tackled by core team ASAP and removed need/triage Needs initial labeling and prioritization labels Jan 2, 2025
gammazero added a commit to ipfs/boxo that referenced this issue Jan 3, 2025
* Fix redirect for directories to escape special chars in URL

Directories with a "%" in their name do not work correctly when when redirected to a URL with a trailing slash. When the original URl contains special characters, such as "%", the correcponding redirect URL must escape these characters.

Fixes issue ipfs/kubo#10536

* Test against new gateway-conformance test version
gammazero added a commit that referenced this issue Jan 4, 2025
* fix/gateway: escape directory redirect URLs

When a director gets redirected to a URL with a treailing slash, special chars in the directory name must be escaped in the redirect URL. This upgrades to a version of box that has that fix.

Closes #10536

* Fix sharness test for new redirect URLs
* Update to latest boxo
* Use latest gateway-conformance
lidel pushed a commit that referenced this issue Jan 13, 2025
* fix/gateway: escape directory redirect URLs

When a director gets redirected to a URL with a treailing slash, special chars in the directory name must be escaped in the redirect URL. This upgrades to a version of box that has that fix.

Closes #10536

* Fix sharness test for new redirect URLs
* Update to latest boxo
* Use latest gateway-conformance

(cherry picked from commit b7cc47a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws) P0 Critical: Tackled by core team ASAP
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants