All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jakarta.mvc.security.Encoders Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2014-2015 Oracle and/or its affiliates. All rights reserved.
 * Copyright (c) 2016-2019 JSR 371 expert group and contributors
 * Copyright (c) 2020 Contributors to the Eclipse Foundation
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0, which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * This Source Code may also be made available under the following Secondary
 * Licenses when the conditions for such availability set forth in the
 * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
 * version 2 with the GNU Classpath Exception, which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 */
package jakarta.mvc.security;

import jakarta.mvc.MvcContext;

/**
 * Interface that provides encoders to escape code in JavaScript, HTML,
 * etc. Encoding data is a way to prevent XSS attacks by ensuring it is not
 * misinterpreted as running code. Implementations of this interface are injectable
 * and accessible from EL via the {@link MvcContext} class as {@code mvc.encoders}.
 *
 * @author Santiago Pericas-Geertsen
 * @see OWASP Encoder Project
 * @since 1.0
 */
public interface Encoders {

    /**
     * 

Encoding for JavaScript code in attributes or script blocks. It MUST support * encoding of (at least) the following characters:

* * * * * * * * * * * * * * * * * * * *
Encoding Table
Input CharacterEncoding
U+0008 (BS)\b
U+0009 (HT)\t
U+000A (LF)\n
U+000C (FF)\f
U+000D (CR)\r
/\/
\\\
"\x22
&\x26
'\x27
U+0000-U001F\x##
* * @param s string to encode. * @return encoded string. */ String js(String s); /** *

Encoding for HTML code in attributes or content. It MUST support encoding of * (at least) the following characters:

* * * * * * * * * * * * * *
Encoding Table
Input CharacterEncoding
&&
<&lt;
>&gt;
"&#34;
'&#39;
* * @param s string to encode. * @return encoded string. */ String html(String s); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy