You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by jw...@apache.org on 2011/04/08 23:38:49 UTC
svn commit: r1090459 - in
/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal:
skin/SkinStyleSheetParserUtils.java style/util/CSSUtils.java
style/xml/parse/StyleSheetDocument.java
Author: jwaldman
Date: Fri Apr 8 21:38:49 2011
New Revision: 1090459
URL: http://svn.apache.org/viewvc?rev=1090459&view=rev
Log:
TRINIDAD-2085 absolute urls for icon selectors preprends context-root when it shouldn't
updated to do a more thorough check of if the url is absolute rather than only checking if it starts with http:
Modified:
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/CSSUtils.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetDocument.java
Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java?rev=1090459&r1=1090458&r2=1090459&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java Fri Apr 8 21:38:49 2011
@@ -554,28 +554,33 @@ class SkinStyleSheetParserUtils
// get the string that is inside of the 'url()'
String uriString = _getURIString(propertyValue);
+ boolean isAbsoluteURI = CSSUtils.isAbsoluteURI(uriString);
// a leading / indicates context-relative
// (auto-prefix the servlet context)
// a leading // indicates server-relative
// (don't auto-prefix the servlet context).
-
- boolean startsWithTwoSlashes = uriString.startsWith("//");
- if (!startsWithTwoSlashes && uriString.startsWith("/"))
- {
- uriString = uriString.substring(1);
- }
- else
+ if (!isAbsoluteURI)
{
- // a. if it has two slashes, strip off one.
- // b. if it starts with http: don't do anything to the uri
- // c. if it an absolute url, then it should be relative to
- // the skin file since they wrote the absolute url in the skin file.
- if (startsWithTwoSlashes)
+ boolean startsWithTwoSlashes = uriString.startsWith("//");
+
+ if (!startsWithTwoSlashes && uriString.startsWith("/"))
+ {
uriString = uriString.substring(1);
- else if (!(uriString.startsWith("http:")))
- uriString = CSSUtils.getAbsoluteURIValue(sourceName, baseSourceURI, uriString);
-
+ }
+ else
+ {
+ // a. if it has two slashes, strip off one.
+ // b. if it is an absolute url, don't do anything
+ // c. if it a relative url, then it should be relative to
+ // the skin file since they wrote the relative url in the skin file.
+
+ if (startsWithTwoSlashes)
+ uriString = uriString.substring(1);
+ else
+ uriString = CSSUtils.getAbsoluteURIValue(sourceName, baseSourceURI, uriString);
+
+ }
}
// At this point, URIImageIcons start with '/' or 'http:',
// whereas ContextImageIcons uri do not. This is how we will know which type of
Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/CSSUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/CSSUtils.java?rev=1090459&r1=1090458&r2=1090459&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/CSSUtils.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/CSSUtils.java Fri Apr 8 21:38:49 2011
@@ -19,6 +19,11 @@
package org.apache.myfaces.trinidadinternal.style.util;
import java.awt.Color;
+
+import java.net.URI;
+
+import java.net.URISyntaxException;
+
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
@@ -164,6 +169,26 @@ public class CSSUtils
}
}
+ public static boolean isAbsoluteURI(String uriString)
+ {
+ if (uriString == null)
+ return false;
+ if (uriString.indexOf(':') == -1)
+ return false;
+
+ URI uri;
+ try
+ {
+ uri = new URI(uriString);
+ return uri.isAbsolute();
+ }
+ catch (URISyntaxException e)
+ {
+ _LOG.warning("The URI syntax is incorrect, and can not be verified.");
+ }
+ return false;
+ }
+
/**
* Convert a relative URI values to an absolute URI value.
* For example, if the baseURI is "/trinidad-context/skins/purple" and
Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetDocument.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetDocument.java?rev=1090459&r1=1090458&r2=1090459&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetDocument.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetDocument.java Fri Apr 8 21:38:49 2011
@@ -400,7 +400,7 @@ public class StyleSheetDocument
boolean startsWithASlash = uri.startsWith("/");
Style inlineStyle = propertyMap.isEmpty() ? null : new UnmodifiableStyle(propertyMap);
- if (!startsWithASlash && !uri.startsWith("http"))
+ if (!startsWithASlash && !CSSUtils.isAbsoluteURI(uri))
{
icon =
new ContextImageIcon(uri, uri, width, height, null, inlineStyle);