The title should say it all. I'm in a situation where the content includes double-bracketed expressions (e.g., "[[something like this]]") that are not intended as file or image references.
However, the media module picks up these double-bracketed expressions, interprets them as buggy image references, and removes them altogether from the output. This might be related to #1070708: Validate Media Markup in Content, except that this bug concerns how the media filter processes these expressions on the server side rather than how the javascript translates them on the WYSIWYG editing interface.
I'm wondering if we might be able to return the original input rather than the empty string when one of these double-bracketed expressions is encountered.
Comment | File | Size | Author |
---|---|---|---|
#15 | 1828580-media-double-brackets-15.patch | 550 bytes | longwave |
| |||
#10 | 1828580-media-double-brackets-10.patch | 1.08 KB | longwave |
Comments
Comment #1
ankur CreditAttribution: ankur commentedHere's a patch that changes the
function media_token_to_markup()
, defined in includes/media.filter.inc, to return the original bracketed expression if it could not be converted into a file or image reference.Comment #2
ankur CreditAttribution: ankur commentedComment #3
ParisLiakos CreditAttribution: ParisLiakos commentedhmm, but then the media_tokens that fail rendering would appear as is? that would be bad...users seeing a json string in the middle of the body text would be not desirable.
maybe the best approach here would be to provide a media_tag_pre_render hook there? so lets say markdown converts this tag first if needed.
Did you try giving markdown filter higher presedence in text formats admin screen btw?
so markdown runs first and media then...or markdown try to convert and destroy media tags as well?
Comment #4
Dave ReidI think this should be marked as a duplicate of #1314266: Replace media tag in wysiwyg only if the type equals to "media"
Comment #5
siefca CreditAttribution: siefca commentedI'm not using any WYSIWYG editor, just pure-text BUEditor, and also having this problem. The brackets are removed in PHP code, by filter.
Comment #6
gimpel CreditAttribution: gimpel commentedSame issue here when trying to blog something that uses BASH if tests with double brackets.
Thanks a lot for the patch! That fixed it here.
The patch is still applying fine against alpha2 with some hunks and fixes the issue.
Reopening this one because the other report got closed due to something like a brain fart (sorry).
Comment #7
thisisjusthowidoit CreditAttribution: thisisjusthowidoit commentedI ran across the same issue as 'gimpel' and the patch in this ticket fix it for me.
Will this patch work its way into the next Media release ?
_
Comment #8
longwaveI am running into this problem with some chemical names embedded in my content. As an example I have [[2,2'-[ethylenebis(nitrilomethylidyne)]bis[6-fluorophenolato]]-N,N',O,O']cobalt in a node body and the first part of this is being cut off by the media filter. The patch in #1 worked for me though the files have moved so I am attaching a new patch.
I don't see how it's possible to distinguish between content such as my example and an invalid media tag; I think the filter should just leave unhandled tags alone.
Comment #10
longwaveOops, not running latest -dev on my site. Let's try that again.
Comment #11
digitgopher CreditAttribution: digitgopher commentedFundamentally, what is the reason for buggy image references to be removed from the output? In general if there is a problem I would like to know about it so I can fix it, not make it harder to find.
Another thought is to make the expression syntax even less common. For example [[|*|]] instead of [[*]]. Of course, this is somewhat subjective and cumbersome but at least could help.
Or provide a configuration to let the site admin choose which behavior they want?
Comment #12
longwaveAn alternative fix is to make the regex more specific:
or even
Comment #13
rameshbaddam CreditAttribution: rameshbaddam commentedI like the suggestion from @longwave.
Better to use
define('MEDIA_WYSIWYG_TOKEN_REGEX', '/\[\[{.*?media.*?}\]\]/s');
, this also avoids logs which are in not requiredComment #14
DamienMcKennaAt the very least it should check for [[{something}]] instead of just [[something]].
Comment #15
longwave#10 still applies with fuzz, but the improved regex has been in use on my site for several months now with no issues, so I'm attaching this as a simpler alternative.
Comment #16
joseph.olstadThanks for the patch but it does not apply against 7.x-3.x . This was already fixed /dealt with in the 7.x-3.x branch , please review the 7.x-3.x dev release , see the related issue:
#2825653: MEDIA_WYSIWYG_TOKEN_REGEX in Media Wysiwyg module conflicts with other tokens, using double square brackets [[token]]
We'll fix this in 7.x-2.x once 7.x-3.x gets more mileage/reviews.
Comment #17
joseph.olstad