Author Topic: PCEFX Youtube Embedding Upgrade - No more Adobe Flash, hello HTML5!  (Read 729 times)

TR0N

  • Hero Member
  • *****
  • Posts: 6421
Re: PCEFX Youtube Embedding Upgrade - No more Adobe Flash, hello HTML5!
« Reply #15 on: September 30, 2016, 11:02:46 AM »
Hey Tron, I noticed that too if you type nothing else and just the YouTube link. You must add at least one word, comment or you'll get the error mentioned. I'll see about fixing this though eventually. But typing something extra is a workaround in the meantime. Even just pushing the space bar after the link and typing a '.' or something workarounds it if you have nothing to say.

Alright Tron, I too occasionally fight for the user! I took a look at it now and figured it out! :P

It's SMF Forum code, not this Embed Mod where the problem occurs. Normally, it only excludes "<img>" tags from stripping, so if you used {IMG}{/IMG} by itself in a post, it won't generate an empty message error! The creator of the Youtube Embed Mod was using <object> and <embed> tags for Flash which he'd append to the code AFTER <img>, but I eliminated use of those tags and now use only <iframe> and <audio> for HTML5 support. I needed to reflect this change to this strip check code, below is the before and after changes in "SMF/Sources/Post.php":

Code: [Select]
if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), '<img><object><embed>')) === '')
{
$post_errors[] = 'no_message';
unset($_POST['message']);
}

We needed to change it to '<img><iframe><audio>' to also leave my iframe and audio tags alone, not strip them out and then throw a, "Hey, empty, no message" error:

Code: [Select]
// Let's see if there's still some content left without the tags.
if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), '<img><iframe><audio>')) === '')
{
$post_errors[] = 'no_message';
unset($_POST['message']);
}

The idea is basically to strip out spaces, empty BBC code if you put nothing in it, etc. and then see if that amounts to no string, nothing, etc. then throw a 'no message' error. A Youtube link by itself gets converted to an <iframe></iframe> tag and if that's the ONLY thing in your post, it'd get stripped out, triggering the 'no_message' error...

This code was too cautious to protect against empty posts, in some sense... Commenting the whole thing out works too, but I just appended <iframe><audio> to its exclude list, so whatever.

Anyway, with your reminder of this, I said what the hell, and the fix was easy enough, so there ya go! :) Try again, lemme know!

Ok it worked this time thank you sir may i have another !! Weird little ago it wasn't working i swear the more meddling google does to youtube it often makes it allot more worse.It goes like this  :wink:


PSN:MrNeoGeo
Wii U:Progearspec

NightWolve

  • Hero Member
  • *****
  • Posts: 5277
Re: PCEFX Youtube Embedding Upgrade - No more Adobe Flash, hello HTML5!
« Reply #16 on: October 02, 2016, 06:50:16 AM »
Ok it worked this time thank you sir may i have another !!

Heh-heh.

Quote
Weird little ago it wasn't working

No, you called it correct, I noticed this problem also, and it did need fixing. My new <iframe> and <audio> tags needed to be protected from an overly cautious stripping function.

The forum would be better off if I deleted that PHP code I showed, less CPU time wasted to strip away a post's contents and prove it's ultimately "empty"... Users will fix/edit their own posts themselves if nothing appears anyway by and large...