By Dayo on Monday, 30 January 2017
Posted in Technical Issues
Replies 34
Likes 0
Views 1.1K
Votes 0
So a typical html link would have the form...


<a href="/link-url">link text</a>


EasyDiscuss uses BBCode which has the form ...


[ url=link-url ] link text [ /url ]


Notice how the html link has quotes around the "link-url" while the bbcode does not?
Well, I found that when EasyDiscuss brings in html link from a Joomla article, it makes it into:


[ url=&q uot;ink-url&q uot; ] link text [ /url ]


That is, it wraps this in quote marks and messes up the link.

Had to add spaces here so that stuff will show
Hi Mark,

The issue is simply that there is a bug in "function html2bbcode" which is in /administrator/components/com_easydiscuss/includes/parser/parser.php at around Line 498.

Anything that relies on this function, which converts HTML to BBCode, is affected. In my specific case, it was the content-easydiscuss plugin which uses this function to convert HTML to BBCode when pulling in stuff to EasyDiscuss.

Posts made directly into EasyDiscuss are probably not affected but when html content is pulled in from EasyBlog or elsewhere, it has to run through this function.

I have been able to change the code and solve my issue and I suggest you consider referring this post to your developers as they will immediately see what the issue is and fix it.

As it is impossible to post such markup code here, I have put a quick explanation in the attached txt file.
·
Tuesday, 31 January 2017 22:49
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Dayo,

Not entirely sure how to reproduce this because regardless if there is a quote or no quote (even with html entities) it should translate the link correctly. Can you please provide us with:

1. Back end and FTP access to the site
2. Link to the page that has this errors
·
Monday, 30 January 2017 13:49
·
0 Likes
·
0 Votes
·
0 Comments
·
Thanks for getting back.

To test right here, this is a hyperlink as rendered with quotes and fails:

http://stackideas.com/docs

and here is a canonical bbcode hyperlink:
http://stackideas.com/docs

I expect the first to fail and will test after writing this.
·
Monday, 30 January 2017 19:11
·
0 Likes
·
0 Votes
·
0 Comments
·
Referring to my previous post,

[ url="ht tp:// stackideas .com/docs" ] ht tp:/ / stackideas.com/docs [ /url]

Was the first an invalid bbcode which got mangled because of the quote marks

Don't have ftp to my site but the issue should be clear.

In summary, the conversion from HTML to BBCode should not include the quote marks when converting HTML "a" tags.

This is the bug
·
Monday, 30 January 2017 19:21
·
0 Likes
·
0 Votes
·
0 Comments
·
I have no idea how to replicate this. Can you please attach the contents that you are trying to use to replicate this in a text file so that our forum doesn't convert those text.
·
Tuesday, 31 January 2017 00:14
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi,

Thanks for staying with this.

I have attached a text file with the relevant html section.

I was creating a standalone Joomla page which actually was not supposed to go into EasyDiscuss but was pulled in (thanks for helping sort that now out).

However, the section includes a link which when it got into EasyDiscuss came in "bad".

So main things were, it was created as a Joomla Article, It got pulled into ED, everything else was converted to BBCode nicely, apart from the < a href="example . com" > example . com < /a > tag which ended up with url="example . com" in the BBCode instead of url=example . com as BBCode format should be.

I have put the original HTML from the Joomla content, the converted BBCode from the ED backend and what the link should have been.
·
Tuesday, 31 January 2017 04:41
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Dayo,

Can you download my attachment below and place it inside your /administrator/components/com_easydiscuss/includes/parser/ folder and then re-save the discussion and see how it goes?
·
Tuesday, 31 January 2017 13:12
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi,

I must be missing something as I just did a file diff on both the provided and original parser.php files and there isn't a single difference in the code.

Only difference is that the new one has Unix line endings (LF) and the previous one has Windows line endings (CRLF).
·
Tuesday, 31 January 2017 20:43
·
0 Likes
·
0 Votes
·
0 Comments
·
Okay, I just my hands dirty and went tracking from the content-easydiscuss plugin.

Around Line 662 of /plugins/content/easydiscuss/easydiscuss.php is the following:


$text = ED::parser()->html2bbcode($text);


This ultimately led to "class EasyDiscussParser" in /administrator/components/com_easydiscuss/includes/parser/parser.php ... which was the same as you posted anyway but which had nothing really changed apart from being saved on a Unix machine.

Anyway, looking at "function html2bbcode" in there, the bug jumps out.

Around Line 498, in the regex, you have ...


'[ url = "\1" ] \2 [ /url ]',
NB: Spaces deliberately added to defeat overzealous forum parsing


This is wrong as it wraps \1 in quotation marks and should be ...


'[ url = \1 ] \2 [ /url ]',
NB: Spaces deliberately added to defeat overzealous forum parsing


... to give a proper BBCode format.

Please review and apply fix.

Thats my second bugfix in two weeks of using your otherwise cool tool. Surely a reward is due!

PS: Shouldn't this forum (easydiscuss) not parse items wrapped in code tags and just display as is?
This is basically another bug IMO as it basically stops it from being used in forums that involve sharing code
·
Tuesday, 31 January 2017 21:22
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Dayo,

I would need to review this first but I don't really understand your issue here. Are you having issues submitting bbcode tags or html tags? In your Privacy Policy.txt file, it's html codes.

Can you help me with this so that I can reproduce this locally?

1. Are you using bbcode or a WYSIWYG editor for EasyDiscuss?

2. Based on your last reply, from what I understand you are using the EasyDiscuss content plugin to generate discussions on the forums, correct? Does this issue only occurs with this plugin?
·
Tuesday, 31 January 2017 22:09
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Dayo,

I believe the better way to address this is to fix this in the bbcode parser itself. Rather than changing the behavior of html2bbcode, regardless of the format it uses, with or without double quotes, it should work.

Can you try this instead?
·
Wednesday, 01 February 2017 16:45
·
0 Likes
·
0 Votes
·
0 Comments
·
Sorry, please try this instead. This also fixes issues with single quotes
·
Wednesday, 01 February 2017 16:47
·
0 Likes
·
0 Votes
·
0 Comments
·
Also, you might want to try this on a brand new reply / post because EasyDiscuss does store a cache of the compiled bbcode text into the preview column to save CPU when displaying the posts.
·
Wednesday, 01 February 2017 16:48
·
0 Likes
·
0 Votes
·
0 Comments
·
Sure. Thanks.

I see what you have done with the regex in function replaceBBCodeURL. This will help resolve cases where users wrongly put quote marks in when creating hyperlinks with BBCode.

Note the use of "wrongly" as the Canonical BBCode for the URL tag does not include quotation marks. Alternative Canonical BBCode Link

As said though, it is good to transparently catch and fix such user errors but EasyDiscuss should not itself generate wrongly formatted BBCode by putting such quote marks in as function html2bbcode did before. I note that the parser.php file you attached does rightly also include the fix to function html2bbcode notwithstanding your earlier comment about not changing its behaviour.

Only last thing since you are trying to catch stuff by adding the "& quot ;" html entity is whether you also want to catch "& apos ;" for single quotes as well.

Thanks again!

BTW, unsubscribing from a thread on this forum does not stop one getting emails from future replies to that thread. Not sure whether this is specific to this forum or whether it is a general issue with EasyDiscuss. I am getting emailed after responses to a thread I have unsubscribed from since yesterday: https://stackideas.com/forums/issue-with-email-notification-and-cronjob#reply-313981
·
Thursday, 02 February 2017 03:30
·
0 Likes
·
0 Votes
·
0 Comments
·
Thanks for the insights on this Dayo, yeah I guess it shouldn't also generate a double quote. Regarding the notification issues, we just released a patch on our site earlier yesterday, https://stackideas.com/forums/forums-updated-1

You shouldn't get notifications anymore when you unsubscribe from a thread.
·
Thursday, 02 February 2017 10:16
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post