<commit_before><?xml version="1.0" encoding="UTF-8"?>

<!--
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<!-- Notes:
     * metadata-complete="true" is used to disable scanning the web application and its libraries for classes that use
       annotations to define components of a web application (Servlets etc.). Thus leading to a faster startup.
-->
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
  version="3.1"
  metadata-complete="true">

  <!-- "absolute-ordering" specifies which web fragment JARs (according to the names in their WEB-INF/web-fragment.xml
       files) have to be scanned for SCIs (javax.servlet.ServletContainerInitializer), fragments and annotations.
       An empty <absolute-ordering/> element configures that none are to be scanned, thus leading to a faster
       startup. -->
  <absolute-ordering />

  <display-name>XWiki</display-name>
  <description>XWiki Application</description>

  <!-- Filter in charge of deciding whether to call the ResourceReferenceHandler Servlet (currently used to handle new
       Resource Types registered as Components) or instead to continue with the rest of the filters and mappings below.
       In the future, the goal is to move more and more Resource handling using the ResourceReferenceHandler Servlet and
       remove the Legacy Action Servlet at some point.

       Note: it is important that this filter be the first filter declared (and thus executed). -->
  <filter>
    <filter-name>RoutingFilter</filter-name>
    <filter-class>org.xwiki.resource.servlet.RoutingFilter</filter-class>
  </filter>

  <!-- Filter that sets a custom encoding to all requests, since usually clients don't specify
       the encoding used for submitting the request, so by default containers fall back to the
       encoding globally configured in their settings. This allows XWiki to use a custom encoding,
       without affecting the whole container (and the other applications hosted). -->
  <filter>
    <filter-name>Set Character Encoding</filter-name>
    <filter-class>org.xwiki.container.servlet.filters.internal.SetCharacterEncodingFilter</filter-class>
    <!-- The encoding to use. This must be the same as the one in xwiki.cfg (hopefully only one
         encoding will be used later). -->
    <init-param>
      <param-name>encoding</param-name>
      <param-value>UTF-8</param-value>
    </init-param>
    <!-- Whether to ignore and override the encoding specified by the client, when this actually
         happens. For example, AJAX requests made through XmlHttpRequests specify UTF-8. When this
         is set to false, the custom encoding is used only when there wasn't any encoding specified
         by the client. -->
    <init-param>
      <param-name>ignore</param-name>
      <param-value>false</param-value>
    </init-param>
  </filter>

  <!-- A filter that allows requests to be saved and reused later. For example when the current request contains an
       expired authentication token, and the authorization module redirects to the login page, all the information sent
       by the client would be lost; this filter allows to save all that information, and after a successful login,
       injects the saved data in the new request. -->
  <filter>
    <filter-name>RequestRestorer</filter-name>
    <filter-class>org.xwiki.container.servlet.filters.internal.SavedRequestRestorerFilter</filter-class>
  </filter>

  <!-- This filter is used to convert the HTML generated by the WYSIWYG editor to wiki syntax -->
  <filter>
    <filter-name>ConversionFilter</filter-name>
    <filter-class>org.xwiki.wysiwyg.filter.ConversionFilter</filter-class>
  </filter>

  <!-- A filter that dispatches requests to the right action depending on the button pressed in the editing form. This
       is needed when javascript is disabled, since the browser cannot send the form data to different URLs depending on
       the button pressed. -->
  <filter>
    <filter-name>ActionDispatcher</filter-name>
    <filter-class>com.xpn.xwiki.web.ActionFilter</filter-class>
  </filter>

  <!-- This filter is used to initialize the XWiki context before processing a request. -->
  <filter>
    <filter-name>XWikiContextInitializationFilter</filter-name>
    <filter-class>com.xpn.xwiki.web.XWikiContextInitializationFilter</filter-class>
  </filter>

  <!-- This filter is used to initialize the XWiki context before processing a REST request. -->
  <filter>
    <filter-name>XWikiRESTContextInitializationFilter</filter-name>
    <filter-class>com.xpn.xwiki.web.XWikiContextInitializationFilter</filter-class>
    <!-- A parameter used to identify the request as a an XML-RPC/REST call -->
    <init-param>
      <param-name>mode</param-name>
      <param-value>2</param-value>
    </init-param>
  </filter>

  <!-- This filter is used to add the 'Content-Type-Script' header to the HTTP response. -->
  <filter>
    <filter-name>Set Content-Script-Type</filter-name>
    <filter-class>org.xwiki.container.servlet.filters.internal.SetHTTPHeaderFilter</filter-class>
    <init-param>
      <param-name>name</param-name>
      <param-value>Content-Script-Type</param-value>
    </init-param>
    <init-param>
      <param-name>value</param-name>
      <param-value>text/javascript</param-value>
    </init-param>
  </filter>
  
  <!-- We need this filter because cross domain request for fonts are not allowed if some headers are not set.
       See https://jira.xwiki.org/browse/XWIKI-11300 for more informations. -->
  <filter>
    <filter-name>Set CORS policy for fonts</filter-name>
    <filter-class>org.xwiki.container.servlet.filters.internal.SetHTTPHeaderFilter</filter-class>
    <init-param>
      <param-name>name</param-name>
      <param-value>Access-Control-Allow-Origin</param-value>
    </init-param>
    <init-param>
      <param-name>value</param-name>
      <param-value>*</param-value>
    </init-param>
  </filter>

  <!-- The Routing Fitler decides how to route all requests and thus must be mapped to handle all incoming requests -->
  <filter-mapping>
    <filter-name>RoutingFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

  <!-- The encoding filter MUST always be the first one, as setting the encoding does not work after accessing the
       request data. -->
  <filter-mapping>
    <filter-name>Set Character Encoding</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher><commit_msg>[Misc] Make it simpler for users to setup short urls<commit_after><?xml version="1.0" encoding="UTF-8"?>

<!--
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<!-- Notes:
     * metadata-complete="true" is used to disable scanning the web application and its libraries for classes that use
       annotations to define components of a web application (Servlets etc.). Thus leading to a faster startup.
-->
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
  version="3.1"
  metadata-complete="true">

  <!-- "absolute-ordering" specifies which web fragment JARs (according to the names in their WEB-INF/web-fragment.xml
       files) have to be scanned for SCIs (javax.servlet.ServletContainerInitializer), fragments and annotations.
       An empty <absolute-ordering/> element configures that none are to be scanned, thus leading to a faster
       startup. -->
  <absolute-ordering />

  <display-name>XWiki</display-name>
  <description>XWiki Application</description>

  <!-- Filter in charge of deciding whether to call the ResourceReferenceHandler Servlet (currently used to handle new
       Resource Types registered as Components) or instead to continue with the rest of the filters and mappings below.
       In the future, the goal is to move more and more Resource handling using the ResourceReferenceHandler Servlet and
       remove the Legacy Action Servlet at some point.

       Note: it is important that this filter be the first filter declared (and thus executed). -->
  <filter>
    <filter-name>RoutingFilter</filter-name>
    <filter-class>org.xwiki.resource.servlet.RoutingFilter</filter-class>
  </filter>

  <!-- Filter that sets a custom encoding to all requests, since usually clients don't specify
       the encoding used for submitting the request, so by default containers fall back to the
       encoding globally configured in their settings. This allows XWiki to use a custom encoding,
       without affecting the whole container (and the other applications hosted). -->
  <filter>
    <filter-name>Set Character Encoding</filter-name>
    <filter-class>org.xwiki.container.servlet.filters.internal.SetCharacterEncodingFilter</filter-class>
    <!-- The encoding to use. This must be the same as the one in xwiki.cfg (hopefully only one
         encoding will be used later). -->
    <init-param>
      <param-name>encoding</param-name>
      <param-value>UTF-8</param-value>
    </init-param>
    <!-- Whether to ignore and override the encoding specified by the client, when this actually
         happens. For example, AJAX requests made through XmlHttpRequests specify UTF-8. When this
         is set to false, the custom encoding is used only when there wasn't any encoding specified
         by the client. -->
    <init-param>
      <param-name>ignore</param-name>
      <param-value>false</param-value>
    </init-param>
  </filter>

  <!-- A filter that allows requests to be saved and reused later. For example when the current request contains an
       expired authentication token, and the authorization module redirects to the login page, all the information sent
       by the client would be lost; this filter allows to save all that information, and after a successful login,
       injects the saved data in the new request. -->
  <filter>
    <filter-name>RequestRestorer</filter-name>
    <filter-class>org.xwiki.container.servlet.filters.internal.SavedRequestRestorerFilter</filter-class>
  </filter>

  <!-- This filter is used to convert the HTML generated by the WYSIWYG editor to wiki syntax -->
  <filter>
    <filter-name>ConversionFilter</filter-name>
    <filter-class>org.xwiki.wysiwyg.filter.ConversionFilter</filter-class>
  </filter>

  <!-- A filter that dispatches requests to the right action depending on the button pressed in the editing form. This
       is needed when javascript is disabled, since the browser cannot send the form data to different URLs depending on
       the button pressed. -->
  <filter>
    <filter-name>ActionDispatcher</filter-name>
    <filter-class>com.xpn.xwiki.web.ActionFilter</filter-class>
  </filter>

  <!-- This filter is used to initialize the XWiki context before processing a request. -->
  <filter>
    <filter-name>XWikiContextInitializationFilter</filter-name>
    <filter-class>com.xpn.xwiki.web.XWikiContextInitializationFilter</filter-class>
  </filter>

  <!-- This filter is used to initialize the XWiki context before processing a REST request. -->
  <filter>
    <filter-name>XWikiRESTContextInitializationFilter</filter-name>
    <filter-class>com.xpn.xwiki.web.XWikiContextInitializationFilter</filter-class>
    <!-- A parameter used to identify the request as a an XML-RPC/REST call -->
    <init-param>
      <param-name>mode</param-name>
      <param-value>2</param-value>
    </init-param>
  </filter>

  <!-- This filter is used to add the 'Content-Type-Script' header to the HTTP response. -->
  <filter>
    <filter-name>Set Content-Script-Type</filter-name>
    <filter-class>org.xwiki.container.servlet.filters.internal.SetHTTPHeaderFilter</filter-class>
    <init-param>
      <param-name>name</param-name>
      <param-value>Content-Script-Type</param-value>
    </init-param>
    <init-param>
      <param-name>value</param-name>
      <param-value>text/javascript</param-value>
    </init-param>
  </filter>
  
  <!-- We need this filter because cross domain request for fonts are not allowed if some headers are not set.
       See https://jira.xwiki.org/browse/XWIKI-11300 for more information. -->
  <filter>
    <filter-name>Set CORS policy for fonts</filter-name>
    <filter-class>org.xwiki.container.servlet.filters.internal.SetHTTPHeaderFilter</filter-class>
    <init-param>
      <param-name>name</param-name>
      <param-value>Access-Control-Allow-Origin</param-value>
    </init-param>
    <init-param>
      <param-name>value</param-name>
      <param-value>*</param-value>
    </init-param>
  </filter>

  <!-- The Routing Filter decides how to route all requests and thus must be mapped to handle all incoming requests -->
  <filter-mapping>
    <filter-name>RoutingFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <!-- Even though the Routing Filter is the first filter, users could add other filters that execute before it,
         like the URLRewriteFilter, and if these filters do a forward, we still want our RoutingFilter to be called. -->
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
    <dispatcher>FORWARD</dispatcher>
  </filter-mapping>

  <!-- The encoding filter MUST always be the first one, as setting the encoding does not work after accessing the
       request data. -->
  <filter-mapping>
    <filter-name>Set Character Encoding</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
{'fraction_non_alphanumeric': 0.10204615284042623, 'fraction_numerical': 0.004314571484604825, 'mean_word_length': 3.4393499709808473, 'pattern_counts': {'":': 0, '<': 278, '<?xml version=': 2, '>': 278, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 20}, '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': '5940893', 'n_tokens_mistral': 4283, 'n_tokens_neox': 4153, 'n_words': 1517}