therealglazou / bluegriffon

BlueGriffon, the Web editor
Mozilla Public License 2.0
300 stars 71 forks source link

blocker encoding bug breaks XML compliance #10

Closed garretwilson closed 8 years ago

garretwilson commented 8 years ago

Using XHTML5 (HTML5 in XML format) with a <pre><code> sequence (which is the semantically correct HTML5 way to represent blocks of source code), BlueGriffon will fail to encode core XML delimiters such as < as the appropriate XML/HTML character entity. This breaks the file and prevents it from being loaded or parsed in an XML aware context. In fact it prevents me from even switching back and forth between WYSIWYG and source views in BlueGriffon!!

Create an XHTML5 document with the wizard. In the source code view, enter the following in the source mode, switch to WYSIWYG mode, and save:

<pre><code>
  new ArrayList&lt;&gt;();
</code></pre>

You'll get the non-well-formed file below:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html><html  xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta  charset="utf-8" />
    <title>Test</title>
    <meta  name="generator"  content="BlueGriffon wysiwyg editor" />
  </head>
  <body>
    <pre><code>
      new ArrayList<>();
    </code></pre>
  </body>
</html>

This file is broken! Note that <> appears instead of &lt;&gt;. This is not just a case of "not formatted like I like it". It is broken! It does not work! It is ruined!

It is impossible for me to use BlueGriffon to correctly use blocks of source code that use e.g. the less-than < character. This is a huge blocker issue.

(This was reported in Bug 676 months ago, but has been ignored there and is still marked as "new". It was also discussed on the forum, with no resolution).

therealglazou commented 8 years ago

Confirming.

therealglazou commented 8 years ago

https://github.com/therealglazou/bluegriffon/commit/bb2b6b791527db77cbb3f115ce51db7d70a711e0

garretwilson commented 8 years ago

@therealglazou , please, please tell me how I can pick up a new version of BG with this bug fixed. You cannot imagine the grief this is causing. Where can I find the nightly builds?

therealglazou commented 8 years ago

What's your platform? OSX ?

garretwilson commented 8 years ago

Windows 10 Pro 64-bit.

therealglazou commented 8 years ago

then sorry, but the Windows builds are far from ready yet...

therealglazou commented 8 years ago

And 1.8 add-ons will not work on 2.0 anyway

garretwilson commented 8 years ago

I don't want an add-on. I just want to be able to edit a document! This bug prevents even BG from opening a file that it saved! It prevents BG from even switching between WYSIWYG and Source Code views.

Why not fix this bug in 1.8? This is such a blocker issue, doesn't it warrant a 1.8.1? Are you abandoning 1.8 even for maintenance?

garretwilson commented 8 years ago

@therealglazou , could you please let me know the status of this? This is a horrible blocker bug. You marked it as closed. But then you said that "the Windows builds are far from ready yet". I asked about back-porting to the 1.8, and you didn't answer. Why can't we get a 1.8.1 version? Do you not agree that this is a huge issue, as it corrupts and breaks certain documents?

garretwilson commented 8 years ago

For completeness, in response to your incorrect assertion in Bug #13 that this is only an XML-related issue, here is the problem in HTML.

Let's say I have the following HTML source code, exactly as HTML5 requests for source code. I enter it into the source code view of BG:

<pre><code>public class FooBar {

  /** Does Foo.
   * &lt;p&gt;Does Bar too!&lt;/p&gt;
   */
  public void doFoo() {
    do {
      <mark>foo();</mark>
   } while(bar());
}</code></pre>

Note two things:

  1. I have used character references &lt; and &gt; because I want <p> to appear in the output and not be recognized as an actual HTML <p> tag.
  2. I have not used character references for <mark> because I want the HTML renderer to recognize this element as a child element of <code>---that is, to actually highlight the section in question.

In BG I then switch to WYSIWYG view. Then I switch back to source code view. BlueGriffon changes my code to this:

<pre><code>public class FooBar {

  /** Does Foo.
   * <p>Does Bar too!</p>
   */
  public void doFoo() {
    do {
      <mark>foo();</mark>
   } while(bar());
}</code></pre>

This has completely different semantics! Now in the rendered page I have a paragraph in the middle of my source code, which is not what I wanted nor what I entered.

When will this be fixed for BlueGriffon 1.8? You can't imagine the pain this is causing, requiring me to maintain the document in two completely separate editors, with elaborate search-and-replace back-and-forths as I take the content into and out of BlueGriffon.

zweibieren commented 3 years ago

My first attempt to use BG as a substitute forDreamWeaver has been a nightmare. Here it is 2021, and the above bug still mangles the unsuspecting developer's code. less-thans were converted to entities. Sadly, I have to abandon BlueGiffon.

As a cherry-on-top, BG also added an entirely fictitious vote to my code: <button class="js-vote-up-btn grid--cell s-btn s-btn__unset c-pointer"

data-controller="s-tooltip" data-s-tooltip-placement="right"

data-selected-classes="fc-theme-primary"><svg

  xmlns="http://www.w3.org/2000/svg"

  class="m0 svg-icon iconArrowUpLg"

  width="36" height="36" viewBox="0 0 36 36"/></button>

<div class="js-vote-count grid--cell fc-black-500 fs-title grid fd-column ai-center"

itemprop="upvoteCount" data-value="0">0

<button class="js-vote-down-btn grid--cell s-btn s-btn__unset c-pointer"

data-controller="s-tooltip" data-s-tooltip-placement="right"

data-selected-classes="fc-theme-primary"><svg

xmlns="http://www.w3.org/2000/svg"

class="m0 svg-icon iconArrowDownLg"

width="36" height="36" viewBox="0 0 36 36"/></button>

<a class="js-post-issue grid--cell s-btn s-btn__unset c-pointer py6 mx-auto"

href="https://superuser.com/posts/1614471/timeline"

data-shortcut="T" data-controller="s-tooltip"

data-s-tooltip-placement="right"><svg

xmlns="http://www.w3.org/2000/svg"

class="mln2 mr0 svg-icon iconHistory"

width="19" height="18" viewBox="0 0 19 18"/></a>