?
avatar joomlolo
joomlolo
13 Aug 2016

Steps to reproduce the issue

using addScript or addStyleSheet, or function from template(the same addScript and addStyleSheet in fact) shape5 template, add "/" at the begining if you put a dot first.
in shape5 option in the head or before /body

<script src="./templates/luxon/js/pace.min.js"></script> ==> this path is going to be modified.
<script src="/templates/luxon/js/pace.min.js"></script> ==>it is ok,no change after
or in index.php:
<?php
$doc = JFactory::getDocument();
$doc->addScript("./js/myscript.js");
?>

result : <script src="/./js/myscript.js"></script>

Expected result

<script src="./js/myscript.js"></script>
<script src="./templates/luxon/js/pace.min.js"></script>

Actual result

<script src="/./js/myscript.js"></script>
<script src="/./templates/luxon/js/pace.min.js"></script>

notice the "/" added at the begining.

System information (as much as possible)

fresh install 3.6.2 or update from 3.6.0 (not sure)

php 7
since joomla update 3.6.1 or 3.6.2 I don't know before it was working whitout any change in the path

tested on 2 servers, same web host 1&1fr

Additional comments

avatar joomlolo joomlolo - open - 13 Aug 2016
avatar ggppdk
ggppdk - comment - 13 Aug 2016

That is the prefixing of the SEF plugin, adding: /joomla_subforder/

$base   = JUri::base(true) . '/';

All regular expressions in the SEF plugin
do not check for a dot (in the negative lookahead) when trying to find urls inside various TAG attibute values, and if not absolute prefix them with: joomla base

Current regex part

(?!/|' . $protocols . '|\#|\')

this would fix it:

(?!/|\.|' . $protocols . '|\#|\')
avatar ggppdk
ggppdk - comment - 13 Aug 2016

But i do not know if excluding ./ is correct,

  • probably current behaviour is correctly adding them the "joomla base"

because all relative urls must be prefixed, right ?
so this is not a bug, it is intended behaviour ?

  • the code that is using these urls, should be aware that all relative urls are prefixed
avatar joomlolo
joomlolo - comment - 13 Aug 2016

Hello ggppdk,

thanks replying,

do you think it is an intended behaviour ? because before 3.6.1 it was not like this.
result of <script src="./js/myscript.js"></script> was <script src="./js/myscript.js"></script>,no change, so I don't know if it is normal, intended.

I would like to know if it is normal and if it can be a problem ?

avatar ggppdk
ggppdk - comment - 13 Aug 2016
  1. Tested in J3.5.1 behavior is the same, the Joomla base prefix is added to the URLs
  2. Also a quick look at the SEF plugin i cannot see the relevant part of the negative look-ahead of the regular expression, being modified last 2-3 years
  3. Also this: js/myscript.js is same as: ./js/myscript.js both relative to the same folder path, why the 2nd case must be treated differently by the SEF plugin ? if it was treated differently, then it would an awkward indirect exclusion case

So since this is intended behavior (?)
and since it was like this for years,
and since you had the SEF plugin always enabled (right ?)

my guess either your site software e.g. template has started adding this "./" recently, (even if some other change in J3.6.x has made the software add "./" ? ,then even in this case the URL has not changed: js/myscript.js is same as: ./js/myscript.js )

The URLs of your site must be made relative to joomla base folder,

  • since this is a requirement of the SEF plugin !?

contact the author of it software

of course someone else may add to this issue, to me it seems that there is no bug

avatar joomlolo
joomlolo - comment - 13 Aug 2016

Ok ggppdk so there is no bug and url like this <script src="/./js/myscript.js"></script is ok, because joomla adds "base prefix"

thanks a lot ggppdk
very nice to you to explain me.

Regards,

Laurent

avatar ggppdk
ggppdk - comment - 13 Aug 2016

you are welcome,

i really appreciate when people say thank you for the time ones spends

but i have feeling you have not read my answer, my answer was quite detailed,
and it reflects the time i spent to make it

if you want to discuss the key points of my answer, sure,

  • please answer on every of the 3 key points

i can be wrong, just answer on them with good arguments
and then if you do it people that make decisions here (i do not make any),

  • will see the bug

i am sorry i could not provide arguments that satisfy you

again you are welcome, thank you

avatar ggppdk
ggppdk - comment - 13 Aug 2016

Also it is very easy

to fix your URLs so that they are no longer relative
and make them absolute
then the absolute URLs will not be touched by the SEF plugin

of course you can ask for the awkward indirect exclusion case, that i explained above
(please take time to read me answer like i took time to answer you)

and make an argument that it needs to be added, and convince people that make decisions of it

again you welcome, regards

avatar ggppdk
ggppdk - comment - 13 Aug 2016

Also you forget that when SEF is ON you also get into your page:

    <base href="http://mydommmm.com/subfolder/" />

So try to guess, what the following do in relation to above base

    <script src="/subfolder/./media/jui/js/html5.js"></script>
    <script src="./media/jui/js/html5.js"></script>
    <script src="media/jui/js/html5.js"></script>

after you find,

  • then explain what is the usefulness of your request ??

it seems to me that there is none

Spoiler tip:

  • disable SEF plugin and manually add the above for 4 lines (including the BASE tag) in your page and then do a "view page source" in your browser and click the 3 URLs

The 1st one will be unaffected by the base tag (i added /subfolder/ to make a point of this you can remove it, from both the base and from the 1st url)
but 2nd and 3rd will be affected by the base

all resulting to the same file

avatar joomlolo
joomlolo - comment - 13 Aug 2016
  1. Tested in J3.5.1 behavior is the same, the Joomla base prefix is added to the URLs Also a quick look at the SEF plugin i cannot see the relevant part of the negative look-ahead of the regular expression, being modified last 2-3 years

I have some servers and when I said it was not like this before, it was because one on my server which was running joomla 3.6.0 didn't have modified the path, that's why I was asking for this and why I was thinking maybe maybe there is a problem.perhaps a problem with this server
Now I have done a fresh install (3.6.2) on this server and path was modified

  1. Also this: js/myscript.js is same as: ./js/myscript.js both relative to the same folder path, why the 2nd case must be treated differently by the SEF plugin ? if it was treated differently, then it would an awkward indirect exclusion case

yes ok, I understand but what I didn't understand was /./myscript.js now it is ok

I really appreciate your help and your explanation

avatar ggppdk
ggppdk - comment - 13 Aug 2016

please see my very last answer because i posted it,
about the same time that you posted yours

  • it explains that patching the SEF plugin will give you no benefit since a BASE tag is added

Thus best place to make sure that your URL is as desired

  • is at the place that it gets created, that is the place that needs whatever fixing is needed, to make it point to where you want it to point.

I don't know what more to say,
have a good Sunday

avatar joomlolo
joomlolo - comment - 13 Aug 2016

everything is ok, have a good Sunday

avatar brianteeman
brianteeman - comment - 13 Aug 2016

So can I close this then?

avatar brianteeman brianteeman - change - 13 Aug 2016
Status New Information Required
avatar ggppdk
ggppdk - comment - 13 Aug 2016

@joomlolo

if you can explain how such a change will give some benefit, in combination to the BASE tag then please explain how

@brianteeman

your decision, probably this can be closed,

since patching SEF plugin to make an exclusion for this type of relative URLs (that start with dot),
is meaningless due the BASE tag (no proof given for some benefit), also why exclude some relative urls on such criteria, SEF plugin is supposed to prefix all relative urls right ?

avatar joomlolo
joomlolo - comment - 14 Aug 2016

you can close if you want, because you write is normal and intended url which start by dot are modified, and path like this is normal : <script src="/./js/myscript.js"></script>

avatar ggppdk
ggppdk - comment - 14 Aug 2016

You only need to explain how this will behave:
and people will see the bug

    <base href="http://mydommmm.com/" />
    <script src="/./media/jui/js/html5.js"></script>
    <script src="./media/jui/js/html5.js"></script>
    <script src="media/jui/js/html5.js"></script>
avatar joomlolo
joomlolo - comment - 14 Aug 2016

the 3 lead to the same, the first and the second become the same <script src="/./media/jui/js/html5.js"></script> with / at the beginning, and the third,no change.
so no problem they lead to the same script.

avatar brianteeman
brianteeman - comment - 14 Aug 2016

Closed

avatar ggppdk
ggppdk - comment - 14 Aug 2016

These are valid URLs (notice the double dot somewhere among the single dots in the first one)

<script src="/./media/.././media/./././../././././media/jui/js/html5.js"></script>
<script src="/./media/jui/js/html5.js"></script>

both the above point to :

/media/jui/js/html5.js

Then if you consider the BASE tag the following URLs are the same as the above

<script src="./media/jui/js/html5.js"></script>
<script src="media/jui/js/html5.js"></script>

If you would want them to be relative to location of the executed PHP file

  • that is not possible because the <base> TAG is added

You must write your code taking so that it works both with SEF OFF and SEF ON,
considering that a <base> TAG is added to the page when SEF is ON, that points to joomla base URL, so:

  • prefix your URLs with the sufolder path (check the folders and find it)
  • do not hard code any absolute path / domain to your URLs, because if your site is moved e.g. you make a localhost copy of your website, then the URLs will get broken

e.g. if you have a 3rd party lib JS or some custom JS that you want to load

$lib_path = '/mylibs/select2';   // path relative to joomla root
$lib_uri = JURI::root(true).$lib_path;
JFactory::getDocument()->addScript($lib_uri.'/select2.min.js');

Add a Comment

Login with GitHub to post a comment