List of usage examples for com.liferay.portal.kernel.util Validator isUrl
public static boolean isUrl(String url, boolean acceptRootRelative)
true if the string is a valid URL based on the rules in URL . From source file:com.liferay.layout.type.controller.test.LayoutTypeURLTest.java
License:Open Source License
@Test public void testGetRegularURLLayoutTypeURL() throws Exception { ThemeDisplay themeDisplay = _initThemeDisplay(); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(); Layout layoutURLType = LayoutLocalServiceUtil.addLayout(TestPropsValues.getUserId(), TestPropsValues.getGroupId(), false, _publicLayout.getLayoutId(), "Link", "Link", "Test invalid URL", LayoutConstants.TYPE_URL, false, null, serviceContext); MockHttpServletRequest mockHttpServletRequest = new MockHttpServletRequest(); mockHttpServletRequest.setAttribute(WebKeys.THEME_DISPLAY, themeDisplay); UnicodeProperties properties = layoutURLType.getTypeSettingsProperties(); properties.setProperty("url", "javascript:alert(1)"); Assert.assertTrue(Validator.isUrl(layoutURLType.getRegularURL(mockHttpServletRequest), true)); }