<commit_before><?xml version="1.0" encoding="UTF-8"?>
<xwikidoc>
<web>Main</web>
<name>LuceneSearch</name>
<language></language>
<defaultLanguage>en</defaultLanguage>
<translation>0</translation>
<parent>Main.Search</parent>
<creator>XWiki.Admin</creator>
<author>XWiki.Admin</author>
<customClass></customClass>
<contentAuthor>XWiki.Admin</contentAuthor>
<creationDate>1252450800000</creationDate>
<date>1277130564000</date>
<contentUpdateDate>1277130564000</contentUpdateDate>
<version>1.1</version>
<title>#if("$!{request.text}"=="")$msg.get("search.page.lucene.title.noquery")#else$msg.get("search.page.lucene.title.query", [$request.text])#end</title>
<template></template>
<defaultTemplate></defaultTemplate>
<validationScript></validationScript>
<comment></comment>
<minorEdit>false</minorEdit>
<syntaxId>xwiki/2.0</syntaxId>
<hidden>false</hidden>
<content>{{velocity}}
$xwiki.jsfx.use("uicomponents/search/search.js", true)##
$xwiki.ssfx.use("uicomponents/search/search.css", true)##
## Disable the document extra data: comments, attachments, history...
#set($docextras = [])
## ===================
## Lucene search
## ===================
## Inputs : $request.text
## Outputs : $list, $isScored
## ===================
## Uncomment this line to overload the maximum list of wiki where to search (also the one listed in the wikis combobox)
## #set($allwikinamelist = ["xwiki", "wiki1", "wiki2"])
##
## Uncomment this line to overload the wikis where to search
## #set($wikinames = "xwiki,wiki,wiki")
##
## Uncomment this line to overload the languages to search
## #set($languages = "default,en,de")
#set ($rssmode = ("$!request.xpage" == 'plain'))
## ---------------
## Space filtering
## ---------------
#set($extraClause = '')
#set($spaces = $xwiki.spaces)
#set($selectedSpace = "$!request.space")
#if($selectedSpace != '' &amp;&amp; !$blacklistedSpaces.contains($selectedSpace))
  #set($extraClause = " AND space:${selectedSpace}")
#end
## ----------------------------------------------------------------------
## Exclude Blacklisted spaces ($blacklistedSpaces is set in xwikivars.vm)
## Also exclude WebPreferences.
## ----------------------------------------------------------------------
#foreach ($blacklistedSpace in $blacklistedSpaces)
  #set ($extraClause = " AND NOT space:${blacklistedSpace}${extraClause}")
#end
#if(!$hasAdmin &amp;&amp; !$isAdvancedUser)
  #set ($extraClause = " AND NOT name:WebPreferences${extraClause}")
#end
## ---------------
## Space macros
## ---------------
#macro(spaceoption $space $selectedSpace)
  &lt;option value="${space}" #if($selectedSpace == $space)selected="selected"#end&gt;$space&lt;/option&gt;
#end
#macro(spaceselect $selectedSpace $spaces)
  &lt;select name="space" title="$msg.get('search.page.bar.spaces.title')"&gt;
    &lt;option value="" #if($selectedSpace == '')selected="selected"#end&gt;$msg.get('search.page.bar.spaces.all')&lt;/option&gt;
    #foreach($space in $spaces)
      #if (!$blacklistedSpaces.contains($space))
        #spaceoption($space $selectedSpace)
      #end
    #end
  &lt;/select&gt;
#end
## ---------------
## Wikis filtering
## ---------------
## Parse provided wikis
#set($wikinamelist = [])
#if (!$wikinames)
  #set($wikinametable = $request.getParameterValues("wikinames"))
  #if (!$wikinametable || $request.wikinames == "")
    #set($wikinametable = $allwikinamelist)
  #end
  #set($wikinames = '')
  #foreach($wikiname in $wikinametable)
    #set($ok = $wikinamelist.add($wikiname))
    #if($wikinames != "")
      #set($wikinames = $wikinames + ",")
    #end
    #set($wikinames = $wikinames + $wikiname)
  #end
  #if (!$xcontext.isMainWiki() &amp;&amp; $wikinames == '')
    #set($wikinames = $xcontext.database)
  #end
#else
  #set($wikinametable = $wikinames.split(", "))
  #foreach($wikiname in $wikinametable)
    #set($ok = $wikinamelist.add($wikiname))
  #end
#end
##
#if($xwiki.isVirtualMode() &amp;&amp; $xcontext.isMainWiki())
  #if(!$allwikinamelist)
    #set($currentwikiname = $xcontext.database)
    ## TODO: add and use a public API method to get the list of wikis instead of doing it "by hand"
    #set($allwikilist = $xwiki.searchDocuments(", BaseObject as obj, StringProperty as prop where doc.fullName=obj.name and doc.fullName&lt;&gt;'XWiki.XWikiServerClassTemplate' and obj.className='XWiki.XWikiServerClass' and prop.id.id=obj.id and prop.id.name='server'"))
    ##
    #set($allwikinamelist = [])
    #foreach($wiki in $allwikilist)
      #set($ok = $allwikinamelist.add($wiki.substring(17).toLowerCase()))
    #end
    ## Make sure the main wiki is part of the list
    #if(!$allwikinamelist.contains($xcontext.mainWikiName))
      #set($ok = $allwikinamelist.add($xcontext.mainWikiName))
    #end
  #end
  ## ---------------
  ## Wikis macros
  ## ---------------
  #macro(wikioption $wikiname $wikinamelist)
    &lt;option value="$wikiname" #if($wikinamelist.contains($wikiname))selected="selected"#end&gt;$wikiname&lt;/option&gt;
  #end
  #macro(wikisselect $wikinamelist $allwikinamelist)
    ## TODO: find a scaling way to handle wikis multiselect, does not use multiple="multiple" for now because it does not looks nice
    &lt;select name="wikinames"&gt;
      &lt;option value="" selected="selected"&gt;$msg.get('search.page.bar.wikis.all')&lt;/option&gt;
      #foreach($wikiname in $allwikinamelist)
        #wikioption($wikiname $wikinamelist)
      #end
    &lt;/select&gt;
  #end
#else
  #if($wikinames == '')
    #set($wikinames = $xcontext.mainWikiName)
  #end
#end
## ---------------
## Query preparation
## ---------------
#set($text = "$!request.getParameter('text')")
#set($query = $text)
#set($utext = $util.encodeURI($query))
#set($defaultItemsPerPage = 30)
#set($itemsPerPage = $util.parseInt("$!{request.perPage}"))
#if($itemsPerPage &lt;= 0)
  #set($itemsPerPage = $defaultItemsPerPage)
#end
## ---------------
## Query form
## ---------------
#if(!$rssmode)
{{html}}
&lt;form action="" id="searchBar"&gt;
  &lt;div class="centered"&gt;
    &lt;label for="text" class="hidden"&gt;$msg.get('search.page.query.label')&lt;/label&gt;
    &lt;input type="text" id="text" name="text" class="searchQuery #if($text == '') defaultText#end" #if($text == '') value="$msg.get('search.page.bar.query.tip')" #else value="${escapetool.xml($text)}" #end title="$msg.get('search.page.bar.query.title')"/&gt;
    #if ($xwiki.isVirtualMode() &amp;&amp; $xcontext.isMainWiki())
      #wikisselect($request.wikinames $allwikinamelist)
    #end
    #spaceselect($selectedSpace $spaces)
    &lt;input type="submit" class="searchButton" value="$msg.get('search.page.bar.submit')" title="$msg.get('search.page.bar.submit.title')"/&gt;
    &lt;div class="searchHelp"&gt;$msg.get('search.page.bar.querytip')&lt;/div&gt;
  &lt;/div&gt;
&lt;/form&gt;
{{/html}}
#end
## ---------------
## Results processing
## ---------------
#if($query != '')
  #set($lucene = $xwiki.getPlugin("lucene"))
  #if($lucene)    
    ## ---------------
    ## Lucene search
    ## ---------------
    #set($searchresults = $lucene.getSearchResults("${query}${extraClause}", '', $wikinames, $!languages))
    #if($searchresults.getHitcount() &gt; 0)
      ## -----------------
      ## Pagination (top)
      ## -----------------
      #if(!$rssmode)
        #set($paginationParameters = {'url' : $doc.getURL('view', "text=${query}&amp;amp;space=${selectedSpace}"), 'totalItems' : $searchresults.getHitcount(), 'defaultItemsPerPage' : $defaultItemsPerPage, 'position': 'top'})

        {{html}}
          #pagination($paginationParameters)
        {{/html}}
      #end
      ## -----------------
      ## Display results
      ## -----------------
      #set($firstIndex = "$!{paginationParameters.firstItem}")
      #if($firstIndex == '')
        #set($firstIndex = "$!request.getParameter('firstIndex')")
        #if($firstIndex == '')
          #set($firstIndex = '0')
        #end
      #end
      #set($firstIndex = $util.parseInt($firstIndex))
      #set($firstIndex = $firstIndex + 1)
      #set($results = $searchresults.getResults("$firstIndex", "$itemsPerPage"))
      #if ($rssmode)
        #set ($list = $util.arrayList)
        #foreach ($item in $results)
          #if ($item.type != "attachment")
            #set ($ok = $list.add(0, "${item.space}.${item.name}"))
          #end
        #end
        #set ($feed = $xwiki.feed.getDocumentFeed($list, $util.getHashMap()))
        #set ($feedURI = $doc.getExternalURL("view"))
        #set ($discard = $feed.setLink($feedURI))
        #set ($discard = $feed.setUri($feedURI))
        #set ($discard = $feed.setAuthor('XWiki'))
        #set ($discard = $feed.setTitle($msg.get('search.rss', [$text])))
        #set ($discard = $feed.setDescription($msg.get('search.rss', [$text])))
        #set ($discard = $feed.setLanguage($xcontext.language))
        #set ($discard = $feed.setCopyright($xwiki.getXWikiPreference('copyright')))
        {{{$xwiki.feed.getFeedOutput($feed, 'rss_2.0')}}}
      #else
        #set ($list = $results)
        #set ($isScored = true)

        {{include document="XWiki.Results"/}}
      #end
      ## -----------------
      ## Pagination (bottom)
      ## -----------------
      #if(!$rssmode)
        #set($paginationParameters.position = 'bottom')

        {{html}}
          #pagination($paginationParameters)
        {{/html}}
        ## ---------------
        ## RSS link
        ## ---------------
        #if($selectedSpace == '')
          #set($rssURL = $xwiki.getURL($doc.fullName, 'view', "xpage=plain&amp;amp;text=${utext}" ))
        #else
          #set($rssURL = $xwiki.getURL($doc.fullName, 'view', "xpage=plain&amp;space=${selectedSpace}&amp;text=${utext}"))
        #end

        {{html}}
          &lt;a href="${rssURL}"&gt;&lt;img src="$xwiki.getSkinFile("icons/silk/feed.gif")" alt="RSS icon"/&gt;$msg.get("search.rss", ["[$escapetool.xml($query)]"])&lt;/a&gt;
        {{/html}}
      #end
    #end
  #else

    {{error}}$msg.get('search.lucene.plugin.notfound')){{/error}}
  #end
#end
#if (!$rssmode)
  ## ---------------
  ## Rebuild processing
  ## ---------------
  #set($lucene = $xwiki.getPlugin("lucene"))
  #if($lucene)
    ## ---------------
    ## Queue
    ## ---------------
    #set ($queuesize = $xwiki.lucene.getQueueSize())
    #if ($queuesize &gt; 0)

      {{info}}$msg.get('search.page.lucene.rebuilding', [${queuesize}]){{/info}}
    #end
  #end## lucene exists
#end## !$rssmode
{{/velocity}}</content></xwikidoc>
<commit_msg>XASEARCH-17: Escaping error when displaying lucene search pagination<commit_after><?xml version="1.0" encoding="UTF-8"?>
<xwikidoc>
<web>Main</web>
<name>LuceneSearch</name>
<language></language>
<defaultLanguage>en</defaultLanguage>
<translation>0</translation>
<parent>Main.Search</parent>
<creator>XWiki.Admin</creator>
<author>XWiki.Admin</author>
<customClass></customClass>
<contentAuthor>XWiki.Admin</contentAuthor>
<creationDate>1252450800000</creationDate>
<date>1277130564000</date>
<contentUpdateDate>1277130564000</contentUpdateDate>
<version>1.1</version>
<title>#if("$!{request.text}"=="")$msg.get("search.page.lucene.title.noquery")#else$msg.get("search.page.lucene.title.query", [$request.text])#end</title>
<template></template>
<defaultTemplate></defaultTemplate>
<validationScript></validationScript>
<comment></comment>
<minorEdit>false</minorEdit>
<syntaxId>xwiki/2.0</syntaxId>
<hidden>false</hidden>
<content>{{velocity}}
$xwiki.jsfx.use("uicomponents/search/search.js", true)##
$xwiki.ssfx.use("uicomponents/search/search.css", true)##
## Disable the document extra data: comments, attachments, history...
#set($docextras = [])
## ===================
## Lucene search
## ===================
## Inputs : $request.text
## Outputs : $list, $isScored
## ===================
## Uncomment this line to overload the maximum list of wiki where to search (also the one listed in the wikis combobox)
## #set($allwikinamelist = ["xwiki", "wiki1", "wiki2"])
##
## Uncomment this line to overload the wikis where to search
## #set($wikinames = "xwiki,wiki,wiki")
##
## Uncomment this line to overload the languages to search
## #set($languages = "default,en,de")
#set ($rssmode = ("$!request.xpage" == 'plain'))
## ---------------
## Space filtering
## ---------------
#set($extraClause = '')
#set($spaces = $xwiki.spaces)
#set($selectedSpace = "$!request.space")
#if($selectedSpace != '' &amp;&amp; !$blacklistedSpaces.contains($selectedSpace))
  #set($extraClause = " AND space:${selectedSpace}")
#end
## ----------------------------------------------------------------------
## Exclude Blacklisted spaces ($blacklistedSpaces is set in xwikivars.vm)
## Also exclude WebPreferences.
## ----------------------------------------------------------------------
#foreach ($blacklistedSpace in $blacklistedSpaces)
  #set ($extraClause = " AND NOT space:${blacklistedSpace}${extraClause}")
#end
#if(!$hasAdmin &amp;&amp; !$isAdvancedUser)
  #set ($extraClause = " AND NOT name:WebPreferences${extraClause}")
#end
## ---------------
## Space macros
## ---------------
#macro(spaceoption $space $selectedSpace)
  &lt;option value="${space}" #if($selectedSpace == $space)selected="selected"#end&gt;$space&lt;/option&gt;
#end
#macro(spaceselect $selectedSpace $spaces)
  &lt;select name="space" title="$msg.get('search.page.bar.spaces.title')"&gt;
    &lt;option value="" #if($selectedSpace == '')selected="selected"#end&gt;$msg.get('search.page.bar.spaces.all')&lt;/option&gt;
    #foreach($space in $spaces)
      #if (!$blacklistedSpaces.contains($space))
        #spaceoption($space $selectedSpace)
      #end
    #end
  &lt;/select&gt;
#end
## ---------------
## Wikis filtering
## ---------------
## Parse provided wikis
#set($wikinamelist = [])
#if (!$wikinames)
  #set($wikinametable = $request.getParameterValues("wikinames"))
  #if (!$wikinametable || $request.wikinames == "")
    #set($wikinametable = $allwikinamelist)
  #end
  #set($wikinames = '')
  #foreach($wikiname in $wikinametable)
    #set($ok = $wikinamelist.add($wikiname))
    #if($wikinames != "")
      #set($wikinames = $wikinames + ",")
    #end
    #set($wikinames = $wikinames + $wikiname)
  #end
  #if (!$xcontext.isMainWiki() &amp;&amp; $wikinames == '')
    #set($wikinames = $xcontext.database)
  #end
#else
  #set($wikinametable = $wikinames.split(", "))
  #foreach($wikiname in $wikinametable)
    #set($ok = $wikinamelist.add($wikiname))
  #end
#end
##
#if($xwiki.isVirtualMode() &amp;&amp; $xcontext.isMainWiki())
  #if(!$allwikinamelist)
    #set($currentwikiname = $xcontext.database)
    ## TODO: add and use a public API method to get the list of wikis instead of doing it "by hand"
    #set($allwikilist = $xwiki.searchDocuments(", BaseObject as obj, StringProperty as prop where doc.fullName=obj.name and doc.fullName&lt;&gt;'XWiki.XWikiServerClassTemplate' and obj.className='XWiki.XWikiServerClass' and prop.id.id=obj.id and prop.id.name='server'"))
    ##
    #set($allwikinamelist = [])
    #foreach($wiki in $allwikilist)
      #set($ok = $allwikinamelist.add($wiki.substring(17).toLowerCase()))
    #end
    ## Make sure the main wiki is part of the list
    #if(!$allwikinamelist.contains($xcontext.mainWikiName))
      #set($ok = $allwikinamelist.add($xcontext.mainWikiName))
    #end
  #end
  ## ---------------
  ## Wikis macros
  ## ---------------
  #macro(wikioption $wikiname $wikinamelist)
    &lt;option value="$wikiname" #if($wikinamelist.contains($wikiname))selected="selected"#end&gt;$wikiname&lt;/option&gt;
  #end
  #macro(wikisselect $wikinamelist $allwikinamelist)
    ## TODO: find a scaling way to handle wikis multiselect, does not use multiple="multiple" for now because it does not looks nice
    &lt;select name="wikinames"&gt;
      &lt;option value="" selected="selected"&gt;$msg.get('search.page.bar.wikis.all')&lt;/option&gt;
      #foreach($wikiname in $allwikinamelist)
        #wikioption($wikiname $wikinamelist)
      #end
    &lt;/select&gt;
  #end
#else
  #if($wikinames == '')
    #set($wikinames = $xcontext.mainWikiName)
  #end
#end
## ---------------
## Query preparation
## ---------------
#set($text = "$!request.getParameter('text')")
#set($query = $text)
#set($utext = $util.encodeURI($query))
#set($defaultItemsPerPage = 30)
#set($itemsPerPage = $util.parseInt("$!{request.perPage}"))
#if($itemsPerPage &lt;= 0)
  #set($itemsPerPage = $defaultItemsPerPage)
#end
## ---------------
## Query form
## ---------------
#if(!$rssmode)
{{html}}
&lt;form action="" id="searchBar"&gt;
  &lt;div class="centered"&gt;
    &lt;label for="text" class="hidden"&gt;$msg.get('search.page.query.label')&lt;/label&gt;
    &lt;input type="text" id="text" name="text" class="searchQuery #if($text == '') defaultText#end" #if($text == '') value="$msg.get('search.page.bar.query.tip')" #else value="${escapetool.xml($text)}" #end title="$msg.get('search.page.bar.query.title')"/&gt;
    #if ($xwiki.isVirtualMode() &amp;&amp; $xcontext.isMainWiki())
      #wikisselect($request.wikinames $allwikinamelist)
    #end
    #spaceselect($selectedSpace $spaces)
    &lt;input type="submit" class="searchButton" value="$msg.get('search.page.bar.submit')" title="$msg.get('search.page.bar.submit.title')"/&gt;
    &lt;div class="searchHelp"&gt;$msg.get('search.page.bar.querytip')&lt;/div&gt;
  &lt;/div&gt;
&lt;/form&gt;
{{/html}}
#end
## ---------------
## Results processing
## ---------------
#if($query != '')
  #set($lucene = $xwiki.getPlugin("lucene"))
  #if($lucene)    
    ## ---------------
    ## Lucene search
    ## ---------------
    #set($searchresults = $lucene.getSearchResults("${query}${extraClause}", '', $wikinames, $!languages))
    #if($searchresults.getHitcount() &gt; 0)
      ## -----------------
      ## Pagination (top)
      ## -----------------
      #if(!$rssmode)
        #set($paginationParameters = {'url' : $doc.getURL('view', "text=${escapetool.url($query)}&amp;amp;space=${escapetool.url($selectedSpace)}"), 'totalItems' : $searchresults.getHitcount(), 'defaultItemsPerPage' : $defaultItemsPerPage, 'position': 'top'})

        {{html}}
          #pagination($paginationParameters)
        {{/html}}
      #end
      ## -----------------
      ## Display results
      ## -----------------
      #set($firstIndex = "$!{paginationParameters.firstItem}")
      #if($firstIndex == '')
        #set($firstIndex = "$!request.getParameter('firstIndex')")
        #if($firstIndex == '')
          #set($firstIndex = '0')
        #end
      #end
      #set($firstIndex = $util.parseInt($firstIndex))
      #set($firstIndex = $firstIndex + 1)
      #set($results = $searchresults.getResults("$firstIndex", "$itemsPerPage"))
      #if ($rssmode)
        #set ($list = $util.arrayList)
        #foreach ($item in $results)
          #if ($item.type != "attachment")
            #set ($ok = $list.add(0, "${item.space}.${item.name}"))
          #end
        #end
        #set ($feed = $xwiki.feed.getDocumentFeed($list, $util.getHashMap()))
        #set ($feedURI = $doc.getExternalURL("view"))
        #set ($discard = $feed.setLink($feedURI))
        #set ($discard = $feed.setUri($feedURI))
        #set ($discard = $feed.setAuthor('XWiki'))
        #set ($discard = $feed.setTitle($msg.get('search.rss', [$text])))
        #set ($discard = $feed.setDescription($msg.get('search.rss', [$text])))
        #set ($discard = $feed.setLanguage($xcontext.language))
        #set ($discard = $feed.setCopyright($xwiki.getXWikiPreference('copyright')))
        {{{$xwiki.feed.getFeedOutput($feed, 'rss_2.0')}}}
      #else
        #set ($list = $results)
        #set ($isScored = true)

        {{include document="XWiki.Results"/}}
      #end
      ## -----------------
      ## Pagination (bottom)
      ## -----------------
      #if(!$rssmode)
        #set($paginationParameters.position = 'bottom')

        {{html}}
          #pagination($paginationParameters)
        {{/html}}
        ## ---------------
        ## RSS link
        ## ---------------
        #if($selectedSpace == '')
          #set($rssURL = $xwiki.getURL($doc.fullName, 'view', "xpage=plain&amp;amp;text=${utext}" ))
        #else
          #set($rssURL = $xwiki.getURL($doc.fullName, 'view', "xpage=plain&amp;space=${selectedSpace}&amp;text=${utext}"))
        #end

        {{html}}
          &lt;a href="${rssURL}"&gt;&lt;img src="$xwiki.getSkinFile("icons/silk/feed.gif")" alt="RSS icon"/&gt;$msg.get("search.rss", ["[$escapetool.xml($query)]"])&lt;/a&gt;
        {{/html}}
      #end
    #end
  #else

    {{error}}$msg.get('search.lucene.plugin.notfound')){{/error}}
  #end
#end
#if (!$rssmode)
  ## ---------------
  ## Rebuild processing
  ## ---------------
  #set($lucene = $xwiki.getPlugin("lucene"))
  #if($lucene)
    ## ---------------
    ## Queue
    ## ---------------
    #set ($queuesize = $xwiki.lucene.getQueueSize())
    #if ($queuesize &gt; 0)

      {{info}}$msg.get('search.page.lucene.rebuilding', [${queuesize}]){{/info}}
    #end
  #end## lucene exists
#end## !$rssmode
{{/velocity}}</content></xwikidoc>

{'fraction_non_alphanumeric': 0.24865533818839544, 'fraction_numerical': 0.0059022323766005046, 'mean_word_length': 3.3364293085655317, 'pattern_counts': {'":': 0, '<': 101, '<?xml version=': 2, '>': 101, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2275296', 'n_tokens_mistral': 7187, 'n_tokens_neox': 6982, 'n_words': 1155}