live search macro have problems with filenames with blankspaces

If I use the live search macro to find a file, confluence don't download this file if the filename has blank spaces. The macro find the file correctly but if I click on the result I get something like this:

The page you requested could not be found. Possible reasons:

The page does not exist.

The page exists, but you are not authorized to view it.

4 answers

This widget could not be displayed.
Davin Studer Community Champion Aug 11, 2014

This is a known bug that hasn't been fixed yet. This is how we have worked around it in our environment. Add this to the "after body" section in custom html in Confluence admin. Just replace the {spakey} and {pagename} sections with your page that has the live search macro ... this keeps it from firing on ever page and possibly causing issues.

<script type="text/javascript">
//This is to bandaid an issue with the livesearch macro where spaces in attachment names are being changed from %20 to %2520.
AJS.toInit(function(){
	var url = window.location.pathname;
	if(url.indexOf('display/{spacekey}/{pagename}') != -1) {
		var runBinderComponentsOld = AJS.Confluence.runBinderComponents;

		AJS.Confluence.runBinderComponents = function(){
			runBinderComponentsOld();

			AJS.$('.search-macro li[data-content-type="attachment"] a').each(function(){
				this.href = this.href.replace(/%2520/g, '%20');
			});
		}
	}
});
</script>

Thank you Davin for this work around. I hope Atlassian will fix this problem in the next releases.

It still has not been fixed by 5.7.4. Is there an option to fix this with out having to do it for every space? I would rather not have to add this for every space we have or might have in the future.

Davin Studer Community Champion Sep 17, 2015

I believe it got fixed in 5.8.5 or something like that.

This widget could not be displayed.

Hello Mark, while testing with Confluence 5.4.4 and livesearch using an imaged named "kamakura 3.jpg" I was able to download the item.

Would it be possible to provide a link to the file in question, along with the Confluence version you are as means to enable further understanding of the scenario?

This widget could not be displayed.

Hi Guilherme, I'm using Confluence 5.5.1. The URL that confluence wants to open is like:

filename is: "Here we are 04-2014.docx"

https://my.domain.com/mod.wiki/download/attachments/20850248/Here%2520we%2520are%252004-2014.docx?version=1&modificationDate=1407412380318&api=v2

I think the blank space aliases in the URL are wrong:

  • in URL given: "%2520"
  • correct alias: "%20"

If I use the global search (for the entire wiki) I get a link with the correct blank space aliases.

This widget could not be displayed.

Thank you Davin for this work around. I hope Atlassian will fix this problem in the next releases.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Monday in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

462 views 6 6
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you