Title: Bad URI when a file name has brackets · Issue #35 · ConvertAPI/convertapi-library-ruby · GitHub
Open Graph Title: Bad URI when a file name has brackets · Issue #35 · ConvertAPI/convertapi-library-ruby
X Title: Bad URI when a file name has brackets · Issue #35 · ConvertAPI/convertapi-library-ruby
Description: When I try to add a watermark to a file with [ or ] in its name, I get #
Open Graph Description: When I try to add a watermark to a file with [ or ] in its name, I get # X Description: When I try to add a watermark to a file with [ or ] in its name, I get #<URI::InvalidURIError: bad URI (is not URI?): "https://v2.convertapi.com/d/p2bempn0sjua63w36zyxjr2d2weq7o34/[dev]+sam...
Opengraph URL: https://github.com/ConvertAPI/convertapi-library-ruby/issues/35
X: @github
Domain: github.com
Links:
Viewport: width=device-width
Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bad URI when a file name has brackets","articleBody":"When I try to add a watermark to a file with `[` or `]` in its name, I get `#\u003cURI::InvalidURIError: bad URI (is not URI?): \"https://v2.convertapi.com/d/p2bempn0sjua63w36zyxjr2d2weq7o34/[dev]+sample.pdf\"\u003e`\n\n```ruby\n\nConvertApi.convert(\n \"watermark-overlay\",\n {\n File: \"./[dev] sample.pdf\",\n OverlayFile: ConvertApi::UploadIO.new(File.open(\"some-other.pdf\")),\n Scale: \"75\",\n Opacity: \"30\",\n Style: \"stamp\"\n },\n from_format: \"pdf\"\n).file.save(\"./sample.watermarked.pdf\")\n#\u003cURI::InvalidURIError: bad URI (is not URI?): \"https://v2.convertapi.com/d/p2bempn0sjua63w36zyxjr2d2weq7o34/[dev]+sample.pdf\"\u003e\n```\n\nIf I try to do it without saving, it will be OK, but the URI provided is not a valid URI nor URL:\n\n```ruby\nConvertApi.convert(\n \"watermark-overlay\",\n {\n File: \"./[dev] sample.pdf\",\n OverlayFile: ConvertApi::UploadIO.new(File.open(SaasAppSettings.instance.watermark_file_path)),\n Scale: \"75\",\n Opacity: \"30\",\n Style: \"stamp\"\n },\n from_format: \"pdf\"\n).file\n\n#\u003cConvertApi::ResultFile:0x0000ffff94106a28\n# @info=\n# {\"FileName\"=\u003e\"[dev] sample.pdf\",\n# \"FileExt\"=\u003e\"pdf\",\n# \"FileSize\"=\u003e121463,\n# \"FileId\"=\u003e\"y0xnqdx161tcmbghnf0x3yjniih0ckek\",\n# \"Url\"=\u003e\"https://v2.convertapi.com/d/y0xnqdx161tcmbghnf0x3yjniih0ckek/[dev]%20sample.pdf\"}\u003e \u003c= invalid!\n# but it should be 'https://v2.convertapi.com/d/f82j2d0chmxv4xqqa45s3kql613al2aj/%5Bdev%5D+sample.pdf'\n```\n\nSo I think it should be fixed on the server. The workaround I found is to patch the `ConvertApi::ResultFile`:\n```ruby\nrequire \"addressable/uri\"\n\nmodule ConvertApi\n class ResultFile\n def url\n Addressable::URI.parse(info[\"Url\"]).normalize.to_s\n end\n end\nend\n```\nwhich requires this gem https://github.com/sporkmonger/addressable.\n\nRuby version 3.2.9 (but I think it does not depend)\nLibrary version 2.0.0 or 3.0.0 (tried on both, but I think it does not depend on library version, since the bug is in the API)\n\n","author":{"url":"https://github.com/DmitryBarskov","@type":"Person","name":"DmitryBarskov"},"datePublished":"2025-08-28T14:41:44.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/35/convertapi-library-ruby/issues/35"}
route-pattern /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) route-controller voltron_issues_fragments route-action issue_layout fetch-nonce v2:6a339bac-b710-124d-d29b-174379181ec2 current-catalog-service-hash 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 request-id C5FC:27383:ADE920:E3468F:697F6BF9 html-safe-nonce b517a16896e99dc416968d00144f403ee16e7785115d87f2e545c14db43a1b32 visitor-payload eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNUZDOjI3MzgzOkFERTkyMDpFMzQ2OEY6Njk3RjZCRjkiLCJ2aXNpdG9yX2lkIjoiNjQ2MTc0MzMzMzI3MzIwMTY1NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 visitor-hmac 88efc49700337f68caca1cd4aeccecad5e24184e9dbcf4047e3c3500fcd9ae16 hovercard-subject-tag issue:3363601860 github-keyboard-shortcuts repository,issues,copilot google-site-verification Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I octolytics-url https://collector.github.com/github/collect analytics-location / fb:app_id 1401488693436528 apple-itunes-app app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/ConvertAPI/convertapi-library-ruby/35/issue_layout twitter:image https://opengraph.githubassets.com/b6b0765a35f7ebda85e856187768ba3b625f1c2af78130ce4cdf03a633a2791f/ConvertAPI/convertapi-library-ruby/issues/35 twitter:card summary_large_image og:image https://opengraph.githubassets.com/b6b0765a35f7ebda85e856187768ba3b625f1c2af78130ce4cdf03a633a2791f/ConvertAPI/convertapi-library-ruby/issues/35 og:image:alt When I try to add a watermark to a file with [ or ] in its name, I get # og:image:width 1200 og:image:height 600 og:site_name GitHub og:type object og:author:username DmitryBarskov hostname github.com expected-hostname github.com None 60279d4097367e16897439d16d6bbe4180663db828c666eeed2656988ffe59f6 turbo-cache-control no-preview go-import github.com/ConvertAPI/convertapi-library-ruby git https://github.com/ConvertAPI/convertapi-library-ruby.git octolytics-dimension-user_id 37071453 octolytics-dimension-user_login ConvertAPI octolytics-dimension-repository_id 133849236 octolytics-dimension-repository_nwo ConvertAPI/convertapi-library-ruby octolytics-dimension-repository_public true octolytics-dimension-repository_is_fork false octolytics-dimension-repository_network_root_id 133849236 octolytics-dimension-repository_network_root_nwo ConvertAPI/convertapi-library-ruby turbo-body-classes logged-out env-production page-responsive disable-turbo false browser-stats-url https://api.github.com/_private/browser/stats browser-errors-url https://api.github.com/_private/browser/errors release 7c85641c598ad130c74f7bcc27f58575cac69551 ui-target full theme-color #1e2327 color-scheme light dark
URLs of crawlers that visited me.