Problem: ox-publish (to html for example) generates incoherent external links for search links like [[file:foo%20bar.org::*h1][link example]]. Suppose the h1 element in "foo bar.html" has ID "#orgffffff", the generated external html anchor link may refer to ID "#org000000".
Probable reason: Different IDs get generated to org-publish-cache, 1 for h1 in "foo bar.org", the other (generated by org-resolve-external-link) for h1 in "foo%20bar.org". I suppose that "org-link-unescape" should be called before written to cache. Emacs : GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30) of 2018-07-05 Package: Org mode version 9.0.9 (9.0.9-68-g492420-elpaplus @ /home/farseer/.emacs.d/elpa/org-plus-contrib-20170807/)