contao/core — Issue #3705: Add slash '/' at the beginning of relative URL for script tag
Author: DyaGa
Created: 2011-12-17 14:43:24+00:00
State: open

Just found an interesting bug in one of the project. And, as I see, it's only Opera specific bug. Tested on last Opera version 11.60 (Windows 7 Win32).

# How to reproduce with demo.

1: In backend settings set `URL suffix` to `/` (slash symbol) and check `Rewrite URLs` -
![example](http://gyazo.com/1a602672e2434bd62b0d5f86bcbeeaa6.png)
http://gyazo.com/1a602672e2434bd62b0d5f86bcbeeaa6.png

2: make some changes in `.htaccess`, just change this:

```
RewriteRule .*\.html$ index.php [L]
```

to this:

```
RewriteRule .*\/$ index.php [L]
```

so, now the system generates liks like this: `http://contao-210/news/` or `http://contao-210/calendar/` (with slash at the end).

3: (This step is important for reproducing this bug!) Go to _Themes > Layouts_. Edit _Default layout_ and make loading one more `MooTools templates` - `moo_slimbox` (There can be any other template that can)
![](http://gyazo.com/333ec6149a912c8cf2e94f265869cbcc.png)
http://gyazo.com/333ec6149a912c8cf2e94f265869cbcc.png

4: Now, for example, open page News - `http://contao-210/news/` (or any other in site structure) in Opera and open Dragonfly (Developer tools for Opera).

5: Go to _Network_ tab and see requests after reloading page. You will see something like this:
![](http://gyazo.com/fadd37e5f7898849740b4af4986c364a.png)
http://gyazo.com/fadd37e5f7898849740b4af4986c364a.png

As you can see, Opera makes two additional wrong requests with status `404 Not Found`. And this requests are written by the System to `$_SESSION['LAST_PAGE_VISITED']` value. And it makes bad redirect after user authentication in system.

# What's the problem?

I didn't find any information but only this [W3Schools article about src Attribute for srcipt tag](http://www.w3schools.com/tags/att_script_src.asp). It says that `URL` possible values for `src` attribute are:

> An absolute URL - points to another web site (like src="http://www.example.com/example.js")
> A relative URL - points to a file within a web site (like src="/scripts/example.js")

As you can see this value could be a _relative URL that points to a file within a web site_ and `src` value starts with slash `/`.

So, I make a change in `PageRegular.php` at line 57 to this:

```php
define('TL_PLUGINS_URL', ($objPage->staticPlugins != '' && !$GLOBALS['TL_CONFIG']['debugMode']) ? $objPage->staticPlugins . TL_PATH . '/' : '/');
```
(just replace `''` with `'/'` at the end) . So, now system generates script tags as:

```html

```

And after this changing Opera doesn't make any bad request:

![](http://gyazo.com/c8f8192812539c68d1e1b918971d4cd3.png)
http://gyazo.com/c8f8192812539c68d1e1b918971d4cd3.png

## Additional
As I see this happens only if we have more than one `script` tag in XHTML code and that is why step 3 needed (in reproducing bug steps).