OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Backslashes in URL

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

Backslashes in URL

Postby tine » Tue Dec 17, 2013 10:46 am

Hi!

I've tried to install the OJS 2.4.3, however none of the stylesheets work, because a backslash is added at the end of my domain...
So instead of example.com we get example.com\

I'm running on IIS 8

Does anyone know what to do?
tine
 
Posts: 3
Joined: Tue Dec 17, 2013 10:42 am

Re: Backslashes in URL

Postby asmecher » Tue Dec 17, 2013 1:09 pm

Hi tine,

Check to see whether your PHP settings have enabled any of the "magic quotes" options; these should be disabled.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 9201
Joined: Wed Aug 10, 2005 12:56 pm

Re: Backslashes in URL

Postby tine » Tue Dec 17, 2013 1:40 pm

Hi, and thanks for your answer!

I've read on php.net that "This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0."
I'm using php 5.4, so that shouldn't be the problem.
tine
 
Posts: 3
Joined: Tue Dec 17, 2013 10:42 am

Re: Backslashes in URL

Postby asmecher » Tue Dec 17, 2013 2:47 pm

Hi tine,

Please try the following and report back:
  • Edit lib/pkp/classes/core/PKPRequest.inc.php
  • Find the line of code in the getBasePath() function:
    Code: Select all
    $path = parse_url(dirname($_SERVER['SCRIPT_NAME']), PHP_URL_PATH);
    Replace that line with the following:
    Code: Select all
    $path = parse_url(dirname(str_replace('\\', '/', $_SERVER['SCRIPT_NAME'])), PHP_URL_PATH);
Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 9201
Joined: Wed Aug 10, 2005 12:56 pm

Re: Backslashes in URL

Postby tine » Tue Dec 17, 2013 3:21 pm

Thanks for the answer.

The problem persists - the url for a stylesheet looks like this: <link rel="stylesheet" href="http://ojs.dev%5C/lib/pkp/styles/pkp.css" type="text/css">
tine
 
Posts: 3
Joined: Tue Dec 17, 2013 10:42 am

Re: Backslashes in URL

Postby primozs » Mon Jan 13, 2014 12:49 pm

Hello,

I am experiencing the same problem. Interesting is that if I go locally (hhtp://localhost) it works correctly, while it does not if I go via internet (http://ojs.domain.si). That means locally everything works fine, while in the second case nothing works, because all links contain %5C after the base URL.

Please help!

Regards, Primož
primozs
 
Posts: 81
Joined: Tue Feb 05, 2013 7:07 am

Re: Backslashes in URL

Postby primozs » Mon Jan 13, 2014 2:09 pm

Hello,

Well, reading it again I think I should stress the problem a bit more. It is not that only CSSes have wrong links. All the links are broken. That means the whole portal is actually done. There is nothing you can click, all the links are broken.

Regards, Primož
primozs
 
Posts: 81
Joined: Tue Feb 05, 2013 7:07 am

Re: Backslashes in URL

Postby JasonNugent » Mon Jan 13, 2014 2:34 pm

hi everyone,

I've done some looking around and it sounds like this may be a symptom of something called 'courtesy redirects' within IIS. IIS will often internally rewrite URLs to include trailing slashes. I'm not sure why you're getting backslashes instead of regular forward ones. Can you read the following blog post and see if a rewrite rule made to your web.config file within IIS, along these lines?

http://www.tugberkugurlu.com/archive/re ... ite-module

The document is pertinent for IIS 7, but may also apply to IIS 8.

Regards,
Jason
JasonNugent
Site Admin
 
Posts: 894
Joined: Tue Jan 10, 2006 6:20 am

Re: Backslashes in URL

Postby primozs » Mon Jan 13, 2014 2:59 pm

Hello,

Thank you for the answer, but I am not sure if I explain the problem good enough.
There was OJS 2.4.2 installed, working without any problems. After update to OJS 2.4.3 (installing full package not via patch) I am experiencing problems. All links have backslash character after the base url. That is
http://ojs.domain.si%5C/lib/pkp/js/lib/jquery/plugins/jquery.tag-it.js
instead of
http://ojs.domain.si/lib/pkp/js/lib/jqu ... .tag-it.js

If I am using local link (local/....) everything works fine, all links are correct.
I am using IIS 7 with PHP 5.5.5 and mySQL 5.6.14

I am thinking in the direction that OJS somehow appends backslash after the base URL. That is one option, the other is that a mysterious backslash came into the DB during the upgrade.

Any idea how to solve it?

Regards, Primož
primozs
 
Posts: 81
Joined: Tue Feb 05, 2013 7:07 am

Re: Backslashes in URL

Postby JasonNugent » Mon Jan 13, 2014 3:26 pm

Hmmm, okay. Can you try something, then? Can you apply the following patch *in reverse* to undo this change?

https://github.com/pkp/pkp-lib/commit/0 ... 40ccb.diff

You can do this with the patch command and the -R flag.

Regards,
Jason
JasonNugent
Site Admin
 
Posts: 894
Joined: Tue Jan 10, 2006 6:20 am

Re: Backslashes in URL

Postby primozs » Mon Jan 13, 2014 8:21 pm

Hello,

Before the upgrade I made a backup copy of the whole directory structure. That means I have previous version of all files.
What do you think if I remove the new file structure and replace it with the old? That should be the same as applying the reverse isn't it?
And what about the DB downgrade? After the code upgrade I ran the "upgrade" on the DB as it says in the upgrade instructions. Are the DB changes such that there will be no problems with running old code on it?

Regards, Primož
primozs
 
Posts: 81
Joined: Tue Feb 05, 2013 7:07 am

Re: Backslashes in URL

Postby JasonNugent » Tue Jan 14, 2014 4:45 am

Hi Primož,

No, you won't be able to downgrade the database easily. The 2.4.3 release included many changes to tables in order to facilitate the new way statistics are collected.

you don't need to completely revert. Just try the small modification I linked to. In fact, this is better for us since doing a small change and solving a problem means that we know where the problem exists specifically, so we can fix it.

Regards,
Jason
JasonNugent
Site Admin
 
Posts: 894
Joined: Tue Jan 10, 2006 6:20 am

Re: Backslashes in URL

Postby primozs » Tue Jan 14, 2014 5:28 am

Hello,

We have found a workaround for the problem. I don`t know it looks like a bug caused as a side effect fixing something in the 2.4.3. We have changed the code back to 2.4.2 and it works for us. I have not looked into details but it might even be that on Linux it works, while we are on IIS and have faced the problem.

Bellow is the changed piece of code. I would like to hear your opinion on it, even if now it works for us.

Thanks for help.

Regards, Primož

-----------------------------------------------------------------------------------
class: @file classes/core/PKPRequest.inc.php

/* ver: 2.43 */
/**
* Get the base path of the request (excluding trailing slash).
* @return string
*/
/*
function getBasePath() {
$_this =& PKPRequest::_checkThis();

if (!isset($_this->_basePath)) {
$path = parse_url(dirname($_SERVER['SCRIPT_NAME']), PHP_URL_PATH);

// Encode charcters which need to be encoded in a URL.
// Simply using rawurlencode() doesn't work because it
// also encodes characters which are valid in a URL (i.e. @, $).
$parts = explode('/', $path);
foreach ($parts as $i => $part) {
$pieces = array_map(array($this, 'encodeBasePathFragment'), str_split($part));
$parts[$i] = implode('', $pieces);
}
$_this->_basePath = implode('/', $parts);

if ($_this->_basePath == '/' || $_this->_basePath == '\\') {
$_this->_basePath = '';
}
HookRegistry::call('Request::getBasePath', array(&$_this->_basePath));
}

return $_this->_basePath;
}
*/


/* ver : 2.42 */
function getBasePath() {
$_this =& PKPRequest::_checkThis();

if (!isset($_this->_basePath)) {
$_this->_basePath = dirname($_SERVER['SCRIPT_NAME']);
if ($_this->_basePath == '/' || $_this->_basePath == '\\') {
$_this->_basePath = '';
}
HookRegistry::call('Request::getBasePath', array(&$_this->_basePath));
}

return $_this->_basePath;
}
primozs
 
Posts: 81
Joined: Tue Feb 05, 2013 7:07 am

Re: Backslashes in URL

Postby JasonNugent » Tue Jan 14, 2014 6:50 am

Hi Primož,

What you've done is replace the 2.4.3 function with the 2.4.2 version. That is exactly what my patch would have done, that I linked to earlier :)

So now we know where the issue lies. I'll file a bug for this.

Regards,
Jason
JasonNugent
Site Admin
 
Posts: 894
Joined: Tue Jan 10, 2006 6:20 am

Re: Backslashes in URL

Postby JasonNugent » Wed Jan 15, 2014 5:07 am

Hi everyone,

Michael, our developer who originally worked on this, has a provisional fix for the IIS problem. For those experiencing it, please undo any changes you have made in the last day or so, and then apply this change, which is just a single line of code:

https://github.com/MichaelThessel/pkp-l ... 66376b8424

If that solves your problem, I will merge it into the general codebase.

Regards,
Jason
JasonNugent
Site Admin
 
Posts: 894
Joined: Tue Jan 10, 2006 6:20 am

Next

Return to OJS Technical Support

Who is online

Users browsing this forum: Google [Bot] and 1 guest