@Test public void isEscaped() { Assert.assertFalse(UrlUtil.isEscaped(null)); Assert.assertTrue(UrlUtil.isEscaped("/content/dam/test.png")); Assert.assertTrue(UrlUtil.isEscaped("/content/dam/test%20asset.png")); Assert.assertTrue(UrlUtil.isEscaped("/content/dam/test%20asset.png/_jcr_content")); Assert.assertTrue(UrlUtil.isEscaped("/content/dam/testasset.png/_jcr_content")); Assert.assertTrue(UrlUtil.isEscaped("/content/dam/test%20folder/ir%c4%81%2bpu%20p%c3%b6%20%26p%c3%aep%e2%98%83.jpeg/_jcr_content/test")); Assert.assertFalse(UrlUtil.isEscaped("/content/dam/test asset.png")); Assert.assertFalse(UrlUtil.isEscaped("/content/dam/test asset.png/jcr:content")); Assert.assertFalse(UrlUtil.isEscaped("/content/dam/testasset.png/jcr:content")); Assert.assertFalse(UrlUtil.isEscaped("/content/dam/test folder/irā+pu pö &pîp☃.jpeg/jcr:content/test")); }
public static final boolean isEscaped(final String candidate) { if (candidate == null) { return false; } String unescaped = Text.unescape(StringUtils.stripToEmpty(candidate)); unescaped = StringUtils.replace(unescaped, "/_jcr_content", "/jcr:content"); if (!StringUtils.equals(unescaped, candidate)) { return true; } if (StringUtils.equals(escape(candidate, false), candidate)) { return true; } return false; }
UrlUtil { public static final boolean isEscaped(final String candidate) { if (candidate == null) { return false; } String unescaped = Text.unescape(StringUtils.stripToEmpty(candidate)); unescaped = StringUtils.replace(unescaped, "/_jcr_content", "/jcr:content"); if (!StringUtils.equals(unescaped, candidate)) { return true; } if (StringUtils.equals(escape(candidate, false), candidate)) { return true; } return false; } }
UrlUtil { public static final boolean isEscaped(final String candidate) { if (candidate == null) { return false; } String unescaped = Text.unescape(StringUtils.stripToEmpty(candidate)); unescaped = StringUtils.replace(unescaped, "/_jcr_content", "/jcr:content"); if (!StringUtils.equals(unescaped, candidate)) { return true; } if (StringUtils.equals(escape(candidate, false), candidate)) { return true; } return false; }  }
UrlUtil { public static final boolean isEscaped(final String candidate) { if (candidate == null) { return false; } String unescaped = Text.unescape(StringUtils.stripToEmpty(candidate)); unescaped = StringUtils.replace(unescaped, "/_jcr_content", "/jcr:content"); if (!StringUtils.equals(unescaped, candidate)) { return true; } if (StringUtils.equals(escape(candidate, false), candidate)) { return true; } return false; }  static final String escape(final String unescaped); static final String escape(final String unescaped, final boolean preventDoubleEscaping); static final boolean isEscaped(final String candidate); }
UrlUtil { public static final boolean isEscaped(final String candidate) { if (candidate == null) { return false; } String unescaped = Text.unescape(StringUtils.stripToEmpty(candidate)); unescaped = StringUtils.replace(unescaped, "/_jcr_content", "/jcr:content"); if (!StringUtils.equals(unescaped, candidate)) { return true; } if (StringUtils.equals(escape(candidate, false), candidate)) { return true; } return false; }  static final String escape(final String unescaped); static final String escape(final String unescaped, final boolean preventDoubleEscaping); static final boolean isEscaped(final String candidate);  }