While the field stores both the full path and the video-id, it does not sufficiently process the video-id portion of certain URLs, which results in a DB error.

For example, the URL: http://www.youtube.com/watch?v=1SqBdS0XkV4#1234, results in a video-id of 1SqBdS0XkV4#1234, which exceeds the 15 characters allowed in the `video_id` DB field.

Expected results:

Long Video ID values are either rejected as invalid, or trimmed with a warning.

Actual results:

A DB error, as follows.

PDOException: SQLSTATE[22001]: String data, right truncated: 1406 
Data too long for column 'field_youtube_video_video_id' at row 1: 
INSERT INTO {field_data_field_youtube_video} 
	(entity_type, entity_id, revision_id, bundle, delta, language, field_youtube_video_input, field_youtube_video_video_id) 
	VALUES 
	(:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7); 
Array ( 
	[:db_insert_placeholder_0] => node 
	[:db_insert_placeholder_1] => 36 
	[:db_insert_placeholder_2] => 151 
	[:db_insert_placeholder_3] => testimonial 
	[:db_insert_placeholder_4] => 0 
	[:db_insert_placeholder_5] => und 
	[:db_insert_placeholder_6] => http://www.youtube.com/watch?v=1SqBdS0XkV4#1234 
	[:db_insert_placeholder_7] => 1SqBdS0XkV4#1234 
) 
in field_sql_storage_field_storage_write() (line 451 of .../field/modules/field_sql_storage/field_sql_storage.module).

Comments

leeomara’s picture

Issue summary: View changes
guschilds’s picture

Status: Active » Needs review
StatusFileSize
new613 bytes

Hey leeomara,

The problem here is that '#1234' should have never made it into the video ID. This is a problem with the newest regex that parses the ID from a given URL.

The relevant discussions I find online lead me to believe that a video ID can only contain A-Z, a-z, 0-9, '-', and '_'. This means it is safe for us to remove '#' and anything that follows it (such as time information) when getting the video ID. I suppose this would prevent others from intentionally embedding a video that starts at a specific time. Is that what you were trying to do?

The attached patch fixes the problem with the above suggestion. Please test it and get back to me.

Thanks,
Gus

  • guschilds committed d5f5bcd on 7.x-1.x
    Issue #2276765 by leeomara, guschilds: Fixed bug when '#' is in a...
guschilds’s picture

Title: Long URL causes DB error » A '#' character in the URL causes database error
Status: Needs review » Fixed

The fix for this has been committed. It is now available in the dev release and will be available in the next stable release as well. Thanks for letting us know about it!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.