Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#10252 closed defect (bug) (fixed)

URL of original picture is not inserted into post - problem with filename

Reported by: pavelevap's profile pavelevap Owned by:
Milestone: 2.9 Priority: high
Severity: normal Version: 2.8
Component: Media Keywords: has-patch tested
Focuses: Cc:

Description

I uploaded picture Aktivní_stáj_schéma.jpg. Then select Thumbnail and set Link URL to original picture file. Then tried to insert into post. But only following code (with missing URL) appears:

<a href=""><img src="http://localhost.cz/Wordpress/wp-content/uploads/2009/06/Aktivní_stáj_schéma-300x148.jpg" alt="Aktivní_stáj_schéma" title="Aktivní_stáj_schéma" width="300" height="148" class="aligncenter size-medium wp-image-5503" /></a>

I tried also 2.8.1-beta1, but in this case thumbnail was not probably created and after inserting into post there is another problem with URL link to original file:

<a><img class="aligncenter size-medium wp-image-5" title="Aktivní_stáj_schéma" src="http://localhost.cz/wp-content/uploads/Aktivní_stáj_schéma-300x300.jpg" alt="Aktivní_stáj_schéma" width="300" height="300" /></a>

It is not problem of unique picture, because I renamed it to Test.jpg and then everything worked.

Attachments (3)

Auto na dálkové ovládání.jpg (32.9 KB) - added by pavelevap 14 years ago.
10252.2.patch (534 bytes) - added by hakre 14 years ago.
(fixed patch after review by sivel)
10252.patch (534 bytes) - added by hakre 14 years ago.
(fixed patch after review by sivel)

Download all attachments as: .zip

Change History (22)

#1 @pavelevap
14 years ago

  • Cc pavelevap@… added

#2 @ryan
14 years ago

Possibly related to #9416

#3 @pavelevap
14 years ago

It is very strange, it is probably problem of some characters, for example "ě, é, etc." and I encounter this problem on PHP 5.2.6 and higher with safe_mode = Off (I do not know if it is relevant, not too many sites to test). On one server it works for me, but another user told me that he has similar problem - is it posssible that it is not related to server configuration?

#4 @hakre
14 years ago

Hi pavelevap,

thanks for reporting the issue. This looks like an ecoding/filter related problem. It would be helpfull if you can attach the image to this ticket with it's original filename so being available for tests.

Please report if your blog is using UTF8 encoding or something else.

I assume the strangeness "appears" because of colorfull validation/filter/encoding concepts that pop here and there in the core code so that this might look strange. A in-depth analysis will clarify what is going on. Your picture is needed for it.

#5 @hakre
14 years ago

Additionally it would be helpfull if you can provide the operating system / browser you are using for uploading the picture.

#6 @pavelevap
14 years ago

Hi, picture attached. But it is not probably problem of picture (or its format but only filename, you can test it with names for example "Aktivní stáj schéma.jpg" etc. - when I tried to rename this picture, for example as Test.jpg, then everything works well). I am using UTF8 encoding, this issue is not probably browser-related (I tested IE8 and Firefox 3.5.x), I use Windows Vista. I tested also latest WP 2.9-rare and there is no thumbnail created with this filename... Thank you very much for your help, because it is very annoying issue...

#7 @hakre
14 years ago

Nice picture. I'll check that.

#8 @hakre
14 years ago

Confirmed. Uploading the picture, inserting it with having the link to the file explicitly does not survive submitting the posts content to update the database. Link is removed in editor as well.

A check of the posts HTML Data in the database reveals that the link is not saved in the database either. analyzing the HTML in the javascript editor, it is in there while editing.

So the href is removed after the post save action has been triggered and before the data is put into the database.

#9 @hakre
14 years ago

The "Insert into Post"-Button of the Gallery tab of the "Add an Image" Thickbox-Dialog does not work. It inserts the image enclosed with an a-tag that has an empty href attribute. You can reproduce this easily be adding images in the HTML-Mode of the editor:

[caption id="attachment_29890" align="alignnone" width="640" caption="Auto na dálkové ovládání"]<a href=""><img src="http://example.com/wp-content/uploads/2009/09/Auto-na-dálkové-ovládání.jpg" alt="Auto na dálkové ovládání" title="Auto na dálkové ovládání" width="640" height="444" class="size-full wp-image-29890" /></a>[/caption]

Looks like this is in the javascript domain.

#10 @hakre
14 years ago

I tried to get an insight but I really have no clue which javascript that button is triggering and then which tinymce code is exectuted afterwards. Someone with more experience here need to take a look into it.

#11 @hakre
14 years ago

sivel had some ideas in irc

sivel hakre: I think that JS might be what you are looking for | Sep 21 12:45:15 2009
sivel actually there is even some js output by that function | Sep 21 12:44:24 2009
sivel perhaps it keys off of the form submission | Sep 21 12:44:17 2009
sivel the media_upload_type_url_form function looks like where we need to start

Source

#12 @hakre
14 years ago

I found the cause of this behaviour. WordPress right now is unable to properly escape URIs which leed to a total delete of URIs like those.

The underlying bug is of a not working function called esc_url(). I opened a ticket for it: #10859

#13 @hakre
14 years ago

  • Keywords has-patch added

Thankfully there is another function calles esc_attr() that should do everything needed for the output.

Tested for work/fix: OK.

@hakre
14 years ago

(fixed patch after review by sivel)

@hakre
14 years ago

(fixed patch after review by sivel)

#14 @hakre
14 years ago

  • Keywords tested added

#15 @azaozz
14 years ago

  • Milestone changed from 2.8.5 to 2.9

#16 @azaozz
14 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [12051]) Properly escape filename when sending to editor, props hakre sivel, fixes #10252

#17 follow-up: @pavelevap
14 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Is it possible to add this fix also to upcoming version 2.8.5? It is very annoying for non-english websites...

#18 in reply to: ↑ 17 @hakre
14 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

Replying to pavelevap:

Is it possible to add this fix also to upcoming version 2.8.5? It is very annoying for non-english websites...

Hi pavelevap, I have the full understanding for what you say but 2.8.5 is for security issues only. It's better to leave it with the 2.9 version and in that version it is closed because it's fixed.

Hopefully not only this current location but also the general bug in the esc_url() function is fixed in 2.9 then which should increase the overall compability with non alnum chars.

So please leave this ticket as fixed because it's fixed for milestone 2.9.

#19 @pavelevap
14 years ago

OK, thank you for explanation...

Note: See TracTickets for help on using tickets.