Skip to content

Commit

Permalink
XCOMMONS-2830: Introduce a utility component to check if a string con…
Browse files Browse the repository at this point in the history
…tains Velocity code

* Remove the interface as the component is internal.
  • Loading branch information
michitux committed Oct 20, 2023
1 parent a57e4a3 commit 245cefc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 50 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,28 @@
*/
package org.xwiki.velocity.internal.util;

import org.xwiki.component.annotation.Role;
import javax.inject.Singleton;

import org.xwiki.component.annotation.Component;

/**
* Utility role to detect velocity scripts.
* Utility component to check if a string contains a velocity script.
*
* @version $Id$
* @since 15.9RC1
*/
@Role
public interface VelocityDetector
@Component(roles = VelocityDetector.class)
@Singleton
public class VelocityDetector
{
/**
* Checks if a string contains a velocity script.
*
* @param input the string to check
* @return true if the string contains a velocity script, false otherwise
*/
boolean containsVelocityScript(String input);
public boolean containsVelocityScript(String input)
{
return input.contains("#") || input.contains("$");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ org.xwiki.velocity.internal.DefaultVelocityContextFactory
org.xwiki.velocity.internal.DefaultVelocityManager
org.xwiki.velocity.internal.InternalVelocityEngine
org.xwiki.velocity.internal.ServicesVelocityContextInitializer
org.xwiki.velocity.internal.util.DefaultVelocityDetector
org.xwiki.velocity.internal.util.VelocityDetector
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* Tests for {@link DefaultVelocityDetector}.
* Tests for {@link VelocityDetector}.
*
* @version $Id$
*/
@ComponentTest
class DefaultVelocityDetectorTest
class VelocityDetectorTest
{
@InjectMockComponents
private DefaultVelocityDetector detector;
private VelocityDetector detector;

@ParameterizedTest
@CsvSource({
Expand Down

0 comments on commit 245cefc

Please sign in to comment.