Special characters in page titles

It appears that Xwiki allows the use of special characters in page titles, e.g. I can create a page with title
‘foo | bar’ or ‘foo / bar’. However, since the page title also forms the URL for the page access, some characters may create trouble later on and makes it difficult or even impossible to access the page.

Is there a way to restrict the use of such characters for a page title, or modify the method how a page title forms the URL?

Thanks
Rolf

Hi, there’s no built-in way to restrict characters in page names since we worked hard to allow all characters to work well :slight_smile: The only issue I know about is with Tomcat which is configured by default to disallow / and \ in URLs but this can be configured, see http://platform.xwiki.org/xwiki/bin/view/AdminGuide/InstallationTomcat#HAllowing222F22inpagenames

If you really really need to change that (we don’t recommend it since that will make your future upgrades harder), you could modify create_inline.vm (or override it in a custom skin) or the CreateAction.java class. But it’s not easy and I don’t know the exact places you’d need to modify (you’ll need to understand the code there).

I know this is an older question but i encountered the problem with the ‘/’ character.

Xwiki allowed to create a page title with a ‘/’ in it but after creation the page gives an error 404 not found by clicking the page through the menu.

Is there a way to rename the page or delete it while i am unable to browse the page directly ?

Yes, by doing it in a script, see http://snippets.xwiki.org/xwiki/bin/view/Extension/Delete%20page%20programatically/

Maybe an beginners question, but how can, or do, i run this script ?

never mind, i overlooked the guide lines…

I have a similar problem (xwiki 12.10.3) . Someone has created a page called “Tools / Stuff”. The page is in the left nav menu. I cannot navigate to the page, when I click the left nav menu item it says the page does not exist.

I tied the script mentioned above. I dont understand the text in the script “Fill in the name of the space of the page (all path to the page separated by dot). For nested pages, this needs to be the full name of the page, and the pagename (under) will be WebHome.” The page is at the top level so I put WebHome; is that what it means?

When I previewed delete it says the page does not exist. How can I delete the page and or remove the link from the left nav menu?
Thanks

Hello. If you’re using Tomcat please see Tomcat Installation (XWiki.org)

PS: We don’t support old versions of XWiki on this forum. We recommend that you upgrade to XWiki 14.10.x which is supported and contains a lof fixes, improvements and security issues fixed since 12.10.x.

Here is a little helper script:

This document checks if there are wiki pages with "/" in their names. These cannot be edited in the normal way.


This allows the renaming of such documents.


{{velocity}}
#if ("$!request.listenElement" != "")
  #set($parList = $request.getParameterValues('listenElement'))
selected are:
  #foreach($number in $parList)
    #set ($pageReference=$request.getParameterValues("original_$number")[0])
    #set ($newPageReference=$request.getParameterValues("neu_$number")[0])
* $pageReference
* $newPageReference
    #set ($discard=$xwiki.getDocument($pageReference).rename($newPageReference))
----
 #end
##
#else
##
## get document list
##

{{html wiki="true"}}
#set($pagesWithSlash = $xwiki.searchDocuments("where doc.fullName like '%/%' or doc.name like '%\\%'"))
   <form action="" method="post">
<small> <dl>   
#if ($pagesWithSlash.size()==0)

{{info}}**No problem documents found.**{{/info}}
#else
Please correct the name and mark the elements to be changed
(% style="color:red" %)
Attention: The name must be a full name (containg the spaces) otherwise new spaces are generated.(%%)

#foreach ($x in $pagesWithSlash)
#set ($value="$velocityCount")
<dt>  $velocityCount : <input type="checkbox" name="listenElement" value="$value"></input> 
       <input name="original_$velocityCount" value="$x" style="visibility:hidden" size="0"></input> </dt>
       <dd>$x<br/>
       #set ($size=$x.length()+30)
       <input name="neu_$velocityCount" value="$x" size="$size"></input>
       </dd>
#end
<hr>
  <input style="left-margin:260px" type="submit" class="button" value="change marked documents" />
  </dl>
  </small>
  </form>
  {{/html}}
#end
#end
{{/velocity}}

You get a list of documents with “/” in their name and rename them.

Thanks NorSch, the script fixed it. This was caused by Tomcat, on vmassol’s link I can see the fix for new pages:

Tomcat completely freaks out when there’s a %2F or %5C in URLs and it’s not something that can be changed in XWiki

But only your script can fix the existing pages.
All is sorted now except for some updating

Thanks for the help.

This is not fully correct. You could also change the Tomcat’s config to support / and \ characters :slight_smile:

Also note that by default / and \ are forbidden, see Page Naming Strategies API (XWiki.org)

I didn’t think that it would fix existing pages, it’s good to know that it will.
Thanks

That’s because the problem is not really how pages have been created but simply the fact that, by default, Tomcat refuse to access a page with a / or \ in its name.