Problem/Motivation
- Create a YouTube field on a content type
- On a new piece of content, assign this value to that field:
http://www.youtube.com/watch?v=1SqBdS0XkV4 and http://youtu.be/1SqBdS0XkV4
Expected result: The video_id is parsed as 1SqBdS0XkV4
OR a validation error is thrown.
Actual result: The video_id is parsed as 1SqBdS0XkV4 and http://youtu.be/1SqBdS0XkV4
.
Proposed resolution
My first thought was to simply add a space character to the list of characters that would be ignored/removed. This would parse the proper video_id from the above example. Instead, however, I figured that this wouldn't happen without a mistake and if it wasn't, it should be clear to users why everything after the space is left out. For this reason, I've added a check for inside spaces to the validation and the validation error is thrown in these situations.
Remaining tasks
Review and commit any patches that fix the problem.
Comment | File | Size | Author |
---|---|---|---|
#2 | youtube-video_id-parsing-accepts-spaces-2232459-2.patch | 1.21 KB | guschilds |
Comments
Comment #1
guschilds CreditAttribution: guschilds commentedComment #2
guschilds CreditAttribution: guschilds commentedThe attached patch throws a validation error if a space is found within the supplied input.
It also adds the space character to the list of characters to break on when parsing the video_id for good measure. Somewhat unrelated, the "<" character is also added to the list to avoid any HTML being pushed through (">" was already in there).
Comment #5
guschilds CreditAttribution: guschilds commentedI went ahead and committed the regex changes so the video ID parsing ignores everything after a space. I did not include the addition to the validation in #2's patch.
This will solve the problem originally described, but will not warn the user that they've supplied extraneous information in the field value.