[ 
http://jira.magnolia-cms.com/browse/MGNLSTK-740?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Brad Kazazes updated MGNLSTK-740:
---------------------------------

    Description: 
A common problem I've found when building websites is when a site is made up of 
a combination of http and https pages and also require the use of a common 
external resource. One example of this, which is becoming more popular these 
days, is the use of the Google hosted JQuery library, 
http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js. The main 
problem is when browsers (mainly IE) continuously display errors when 
attempting to accessing unsecured resouces in secured pages. While the external 
resource could be changed to "https", this takes out the benefits of using the 
Google hosted solution.

After some investigation, I recently found out about "Relative References" 
which is described in the URI RFC, 
http://tools.ietf.org/html/rfc3986#section-4.2. This states that URI's can 
safely ignore the protocol handle of the URL which means we can access the 
JQuery, for example, as 
"//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js".

Please see the following site for a great description of this problem and how 
Relative References resolves it: 
http://encosia.com/2011/01/19/cripple-the-google-cdns-caching-with-a-single-character/


Our problem, however, is that I can't enter this type of link into the Theme, 
it is treated as an internal link where the context path is prepended. After 
some digging, I found this is due to the 
info.magnolia.module.templatingkit.resources.Resource.getLink() using the 
info.magnolia.link.LinkUtil.EXTERNAL_LINK_PATTERN to determine if the link is 
external or not; and this pattern doesn't allow for relative references.

The best solution would likely be to update the LinkUtil.EXTERNAL_LINK_PATTERN 
to allow for relative references; however I'm not sure what else depends on 
this pattern. If we can change the pattern, it should be a simple change to

{code}
public static final Pattern EXTERNAL_LINK_PATTERN = 
Pattern.compile("^(\\w*:?//|mailto:|javascript:).*");
{code}

although I haven't actually tested this.


  was:
A common problem I've found when building websites is when a site is made up of 
a combination of http and https pages and also require the use of a common 
external resource. One example of this, which is becoming more popular these 
days, is the use of the Google hosted JQuery library, 
http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js. The main 
problem is when browsers (mainly IE) continuously display errors when 
attempting to accessing unsecured resouces in secured pages. While the external 
resource could be changed to "https", this takes out the benefits of using the 
Google hosted solution.

After some investigation, I recently found out about "Relative References" 
which is described in the URI RFC, 
http://tools.ietf.org/html/rfc3986#section-4.2. This states that URI's can 
safely ignore the protocol handle of the URL which means we can access the 
JQuery, for example, as 
"//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js".

Please see the following site for a great description of this problem and how 
Relative References resolves it: 
http://encosia.com/2011/01/19/cripple-the-google-cdns-caching-with-a-single-character/


Our problem, however, is that I can't enter this type of link into the Theme, 
it is treated as an internal link where the context path is prepended. After 
some digging, I found this is due to the 
info.magnolia.module.templatingkit.resources.Resource.getLink() using the 
info.magnolia.link.LinkUtil.EXTERNAL_LINK_PATTERN to determine if the link is 
external or not; and this pattern doesn't allow for relative references.

The best solution would likely be to update the LinkUtil.EXTERNAL_LINK_PATTERN 
to allow for relative references; however I'm not sure what else depends on 
this pattern. If we can change the pattern, it should be a simple change to 
"^(\\w*:?//|mailto:|javascript:).*"; although I haven't actually tested this.



> Allow Resource.getLink() to support "Relative References" in external links
> ---------------------------------------------------------------------------
>
>                 Key: MGNLSTK-740
>                 URL: http://jira.magnolia-cms.com/browse/MGNLSTK-740
>             Project: Magnolia Standard Templating Kit
>          Issue Type: Improvement
>          Components: base system
>    Affects Versions: 1.3.5, 1.4.2
>            Reporter: Brad Kazazes
>            Assignee: Philipp Bärfuss
>
> A common problem I've found when building websites is when a site is made up 
> of a combination of http and https pages and also require the use of a common 
> external resource. One example of this, which is becoming more popular these 
> days, is the use of the Google hosted JQuery library, 
> http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js. The main 
> problem is when browsers (mainly IE) continuously display errors when 
> attempting to accessing unsecured resouces in secured pages. While the 
> external resource could be changed to "https", this takes out the benefits of 
> using the Google hosted solution.
> After some investigation, I recently found out about "Relative References" 
> which is described in the URI RFC, 
> http://tools.ietf.org/html/rfc3986#section-4.2. This states that URI's can 
> safely ignore the protocol handle of the URL which means we can access the 
> JQuery, for example, as 
> "//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js".
> Please see the following site for a great description of this problem and how 
> Relative References resolves it: 
> http://encosia.com/2011/01/19/cripple-the-google-cdns-caching-with-a-single-character/
> Our problem, however, is that I can't enter this type of link into the Theme, 
> it is treated as an internal link where the context path is prepended. After 
> some digging, I found this is due to the 
> info.magnolia.module.templatingkit.resources.Resource.getLink() using the 
> info.magnolia.link.LinkUtil.EXTERNAL_LINK_PATTERN to determine if the link is 
> external or not; and this pattern doesn't allow for relative references.
> The best solution would likely be to update the 
> LinkUtil.EXTERNAL_LINK_PATTERN to allow for relative references; however I'm 
> not sure what else depends on this pattern. If we can change the pattern, it 
> should be a simple change to
> {code}
> public static final Pattern EXTERNAL_LINK_PATTERN = 
> Pattern.compile("^(\\w*:?//|mailto:|javascript:).*");
> {code}
> although I haven't actually tested this.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.magnolia-cms.com/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira




----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to