Protocol-relative URL

This forum is for questions about contributing to the project or proposing features that you would like to develop for the project. 

This thread is closed to new posts. You must sign in to post in the forums.
7/10/2012 1:01:06 PM
Gravatar
Total Posts 28
~Leslie

Protocol-relative URL

Our organization uses a web proxy to handle our https connections. Because of this, the script links in ScriptLoader.cs and StyleSheetcombiner.ascx.cs  creates all of our connections as http.   When the browser requests the http script links on an https page, there are security warnings stating that insecure content is being requested from a secure page.  Our team lead referred me to a possible solution (http://paulirish.com/2010/the-protocol-relative-url/).  The article discusses the use of a relative path (//) instead of http or https with an image link.  I modified code in the files above (to test) and now, in our IE8 https environment, the pages are rendered correctly with no security messages. 

As far as the file modifications, I removed the variable 'protocol' and all references to it in the code.  For example, in ScriptLoader.cs, around line 974 (GetJQueryBasePath()), I changed the following:

return protocol + "://ajax.googleapis.com/ajax/libs/jquery/" + WebConfigSettings.GoogleCDNjQueryVersion + "/";

to

return "//ajax.googleapis.com/ajax/libs/jquery/" + WebConfigSettings.GoogleCDNjQueryVersion + "/";

I can send you the files I modified if you would like to review them.  Would you consider making this a change in the base code?

Thanks!

Leslie

7/10/2012 1:13:17 PM
Gravatar
Total Posts 18439

Re: Protocol-relative URL

Hi Leslie,

I can make that change for the next release, but you can solve this problem immediately without any code changes by adding a couple of attributes on <portal:ScriptLoader to make it not load the jquery scripts then hard code them into your layout.master using the protocol relative urls

on <portal:ScriptLoader add:

AssumejQueryIsLoaded="true" and AssumejQueryUiIsLoaded="true"

then add your own links to the jquery files in the <head above scriptloader

Best,

Joe

7/10/2012 2:10:01 PM
Gravatar
Total Posts 28
~Leslie

Re: Protocol-relative URL

I'll use the <portal:ScriptLoader until the next release is installed.  Thanks Joe!

7/11/2012 12:17:38 PM
Gravatar
Total Posts 28
~Leslie

Re: Protocol-relative URL

Hi Joe,

I'm sure adding the <Portal:ScriptLoader, etc. is a simple task, but I'm having a difficult time with it.

On layout.Master, I added the properties as follows:

<portal:ScriptLoader ID="ScriptLoader1" AssumejQueryIsLoaded="true" AssumejQueryUiIsLoaded="true" runat="server" />

Where/how do I add the links in the <head above script loader?  Is there a tag that I need to add with it?  Is layout.Master the only file I need to apply the changes to?  I'm getting a JScript runtime error that 'jQuery' is undefined.  I've looked through the mojoPortal documentation and haven't found a helpful solution.

 

Thanks!

Leslie

7/11/2012 12:25:40 PM
Gravatar
Total Posts 18439

Re: Protocol-relative URL

<portal:ScriptLoader should already be there you just add the attributes to the existing control.

Right above <portal:ScriptLoader add:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript" ></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript" ></script>

Hope that helps,

Joe

7/11/2012 2:28:57 PM
Gravatar
Total Posts 28
~Leslie

Re: Protocol-relative URL

Hi Joe,

 

Yes, that helped very much!  Thanks again!

 

Leslie

7/12/2012 10:56:25 AM
Gravatar
Total Posts 28
~Leslie

Re: Protocol-relative URL

Hi Joe,

I have the properties set for <portal:ScriptLoader and the .js links working correctly on layout.Master.  Now I'm wondering if there are similar properties we can apply to <portal:StyleSheetCombiner to allow the link to be changed to relative.  I don't see the same properties for this control.

Thanks again...

Leslie

7/12/2012 11:31:31 AM
Gravatar
Total Posts 18439

Re: Protocol-relative URL

Hi Leslie,

Yes, on <portal:StyleSheetCombiner you can add IncludejQueryUI="false"

and add it directly above the control like this:

<link rel='stylesheet' type='text/css' href='//ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/redmond/jquery-ui.css' />

replacing redmond with whatever jqueryui theme you are using

Hope that helps,

Joe

7/12/2012 12:17:52 PM
Gravatar
Total Posts 28
~Leslie

Re: Protocol-relative URL

Hi Joe,

That did the trick, we're set.  Thanks again for all of your help with this.  I'll be watching for the next release.

~Leslie

You must sign in to post in the forums. This thread is closed to new posts.