Opened 11 years ago

Closed 10 years ago

#10068 closed Bug (fixed)

Default implementation of getUrl fails with protocol relative URLs

Reported by: Alex Lee Owned by: Piotr Jasiun
Priority: Normal Milestone: CKEditor 4.3.2
Component: General Version: 3.0
Keywords: Cc:

Description

CKEditor's default implementation of getUrl(), using a protocol relative URL in CKEDITOR_BASEPATH like

//assets.server.com/ckeditor/ckeditor.js

Returns a URL like

http://assets.server.com//assets.server.com/ckeditor/*

This can be worked around by setting a CKEDITOR_GETURL, but ideally CKEditor itself would be able to handle that.

Change History (9)

comment:1 Changed 11 years ago by Jakub Ś

Status: newpending
Version: 4.0.2 (GitHub - master)

Where do you get this error and in what situation? Does it by any chance happening with IE and images?

Could you describe test case steps to reproduce this error? 8022

comment:2 Changed 11 years ago by Alex Lee

This error is in all cases that CKEDITOR.getUrl() is called. Most notably the language file that CKEditor grabs first is from the wrong resource URL.

This is not related to IE and can be reproduced in any browser.

Steps to reproduce:

  1. Set window.CKEDITOR_GETURL="//localhost/ckeditor/"; (Wherever the path is, however the important thing is that it begins with // instead of http://, which implies http: if the current page is on http: and https: if the current page is on https:.)
  2. Load CKEditor with <script src="//localhost/ckeditor/ckeditor.js"></script>
  3. See that CKEditor loader makes a request for http://localhost//localhost/ckeditor/lang/en.js

For additional information on protocol-relative URLs, see http://paulirish.com/2010/the-protocol-relative-url/

Version 0, edited 11 years ago by Alex Lee (next)

comment:3 Changed 11 years ago by Jakub Ś

Status: pendingconfirmed
Version: 3.0

@Aintaer thank you for the link.

Problem can be reproduced from CKEditor 3.0 in both CKE 3.x and 4.x (v4) branches

To reproduce:

  1. on page where you use editor set:
    <script>
    	window.CKEDITOR_BASEPATH="//localhost/ckeditor/4.0.1.1/ckeditor/"
    </script>
    <script src="//localhost/ckeditor/4.0.1.1/ckeditor/ckeditor.js"></script>
    
  2. Load page with editor

Result:
Base path gets concatenated with domain e.g. http://localhost//localhost/ckeditor...


To work around this problem instead of BASEPATH, set property GETURL:

<script>
window.CKEDITOR_GETURL="//localhost/ckeditor/4.0.1.1/ckeditor/"
</script>
<script src="//localhost/ckeditor/4.0.1.1/ckeditor/ckeditor.js"></script>

comment:4 Changed 11 years ago by Jakub Ś

Similar issue #8243.

comment:5 Changed 10 years ago by Piotrek Koszuliński

Milestone: CKEditor 4.3.2

comment:6 Changed 10 years ago by Piotr Jasiun

Owner: set to Piotr Jasiun
Status: confirmedassigned

comment:7 Changed 10 years ago by Piotr Jasiun

Status: assignedreview

There was no bug in getUrl, because resource.indexOf( '/' ) !== 0 works pretty well with paths which has '' at the begginging. The problem was in basePath which was created incorrectly for protocol-relative paths.

Changes in t/10068 and corresponding test branch.

comment:8 Changed 10 years ago by Piotrek Koszuliński

Status: reviewreview_passed

I rebased both branches and improved tests. They don't try to load CKEditor from non existing external domains, etc. All requests end with successfully. To achieve that I had to introduce CKTESTER.config.secondDomainName. All of us will have to create it, although usually tests pass without it too.

comment:9 Changed 10 years ago by Piotrek Koszuliński

Resolution: fixed
Status: review_passedclosed

Fixed on master with git:50cadb239fd on dev and 80ed976c7 on tests.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy