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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

guschilds’s picture

Issue summary: View changes
guschilds’s picture

Status: Active » Needs review
FileSize
1.21 KB

The 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).

  • Commit 7e5a54f on 7.x-1.x by guschilds:
    Issue #2232459: Added space and HTML tag opening to characters to break...

  • Commit fc15958 on 8.x-1.x by guschilds:
    Issue #2232459: Added space and HTML tag opening to characters to break...
guschilds’s picture

Status: Needs review » Fixed

I 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.

Status: Fixed » Closed (fixed)

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