Moodle

mediaplugin filters capture way too much

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Duplicate
  • Affects Version/s: 1.9.5
  • Fix Version/s: None
  • Component/s: Filters
  • Labels:
    None
  • Difficulty:
    Easy
  • Affected Branches:
    MOODLE_19_STABLE

Description

While taking a look to MDL-19231 I've detected that ALL the regexp used to detect videos/audios.... whatever, are in the form:

$search = '/<a.*?href="([^<]*)youtube.com\/watch?v=([^"]*)"[^>]>(.?)<\/a>/is';

And that .*, no matter of the ? (greedy) after it... seems to be capturing way too much. So any text containing any <a> tag, followed by one URL being processed by the mediaplugin filter.... is really borked (unless I'm forgetting something).

In the filter_mediaplugin_enable_youtube customization, I've replaced it to:

$search = '/<a[^>]*?href="([^<]*)youtube.com\/watch?v=([^"]*)"[^>]>(.?)<\/a>/is';

And now it seems to work ok. Perhaps the same change:

.* ==> [^>]* should be applied to all regexp in that filter. It's really strange nobody has claimed that before (sure I'm missing something).

For your consideration, ciao

Issue Links

Activity

There are no comments yet on this issue.

People

Dates

  • Created:
    Updated:
    Resolved: