Backslash on links before the file name

Asked

Viewed 447 times

1

I was posting an answer to a question from a user of this site when I noticed that in HTML there were image tags with src containing a backslash before the file name

<img src="galerias\001.jpg" id="fotos">

I confess that it was the first time I saw something like this and I did not find any publication that gave me any explanation regarding this type of address in the src attribute.

Is this compatible? Any documentation about this?

1 answer

1


From what I read in the HTML Standard documentation the src attribute of the element has to be a "Potentially empty URL surrounded by valid spaces" (Valid non-empty URL potentially surrounded by Spaces).


And what is a Valid non-empty URL potentially surrounded by Spaces?

It is a valid non-empty URL (Valid non-empty URL) after whitespace has been removed. This leads to the next question:


What is a Valid non-empty URL ?

It is a valid URL string that is not empty. So....


What is a valid URL string?

Now I swear I’ll summarize why there are so many details. It can be relative or absolute. And in both cases and in all scenarios, the documentation I read always cites the U+002F character (/).

So the conclusion is that it can probably work because the browser when interpreting the URL does the correction automatically, but it is not the specification.

link to documentation

  • All this I know, I even played the page of the researcher and posted on my server. Ran round in the five main browsers. Check the source code for backslashes before the file name in the image src http://kithomepage.com/sos/marlonramos.htm @Fabri Damazio

  • 1

    Yes I saw and tested here on my website and it worked normally. But as I wrote there is nothing in the documentation that talks about it. Probably some correction that the browser itself makes when interpreting the url.

  • Curiosity is huge in knowing exactly why it works. I think you’re right in saying that it’s probably a browser fix.

  • 1

    @Should Leocaracciolo images appear in this example of yours? Here it did not appear, but looking at the Chrome inspector, the browser actually changes \ for / when rendering the image.

  • yes, as I said in my first comment above, it ran in the 5 browsers. Fact this corroborated by the friend Fabri Damazio in his first comment. Anderson Carlos Woss, out of curiosity, which version did not work?

  • @Leocaracciolo Chrome, Version 57.0.2987.133 (64-bit) in Linux

  • You gave me a good tip, Inspector, from which it is concluded that Fabri Damazio is right to assume that it is browser correction. If he adds that to the answer, I will elect as accepted.

  • Firefox 52.0.2 (64-bit) also did not open the images. Opera 44.0.2510.1449 also did not open.

  • tonces, good to avoid right.

  • In fact, I think I looked at the source code in the wrong place. In the inspector there was no substitution and, by the way, does not load the image like this. So it’s good to use only / even.

  • It replaces when interpreting and not in the code itself probably. When parsing time

  • Yes, but the inspector shows exactly what the browser is showing on screen. If there was this substitution, the image link would be corrected in it, but continues with the backslash.

  • Do the following test: open this link from an image in the browser bar: https://fabridamazio.github.io/images/face.jpg Now change the last bar by the slider backwards and it will correct automatically. Probably do the same thing when interpreting urls.

  • Leo but when interpreting it should make the correction as it happens when for example we forget to close some tag and still the code works because the browser ends up fixing and closing the tag automatically

Show 9 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.