zoekt icon indicating copy to clipboard operation
zoekt copied to clipboard

URLs for code links are escaping `+`s found in file paths

Open rnc505 opened this issue 1 year ago • 2 comments

What is the problem?

On the results page, if a search result contains a + in the file path, e.g. filename is SwiftFileName+SwiftCategoryName.swift, the URL escapes the + such that it breaks the link.

E.g. if the search result is expected to point to https://github.com/OrganizationName/RepositoryName/path/to/SwiftFileName+SwiftCategoryName.swift, the URL becomes https://github.com/OrganizationName/RepositoryName/path/to/SwiftFileName+SwiftCategoryName.swift, which leads to a broken page.

Why is this a problem?

  • Poor user experience while navigating results
  • The + should not be escaped, it's just wrong

Proposed fix

  • Prevent + from being escaped in result URLs. There might be other symbols getting problematically escaped, but I have not encountered these yet

rnc505 avatar Aug 12 '24 20:08 rnc505

Thanks for the report, should be an easy fix.

keegancsmith avatar Aug 14 '24 12:08 keegancsmith

Awesome, thank you!

rnc505 avatar Aug 14 '24 13:08 rnc505

Briefly looked into it, gets deeper into the weeds with https://github.com/golang/go/issues/42506

  • html/template escapes + to #43 The template is executed here: https://github.com/sourcegraph/zoekt/blob/main/web/snippets.go#L79

stephenlacy avatar Oct 04 '24 19:10 stephenlacy

I thought this would be easy to solve, but it ended up being a pretty deep change. Hopefully https://github.com/sourcegraph/zoekt/pull/843 resolves this for you.

keegancsmith avatar Oct 07 '24 09:10 keegancsmith