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).
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | youtube-hash-url-db-error-2276765-2.patch | 613 bytes | guschilds |
Comments
Comment #1
leeomaraComment #2
guschilds commentedHey 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
Comment #4
guschilds commentedThe 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!