1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed Visible loss of white space from [CODE] code

Discussion in 'Resolved Bug Reports' started by grahamperrin, Aug 28, 2016.

Tags:
  1. grahamperrin

    grahamperrin Member

    Posts such as https://forums.freebsd.org/threads/51009/#post-327495 suffer from this bug. A XenForo site administrator recently sent me a private message emphasising the importance of precision formatting when posting to The FreeBSD forums … and so on.

    The following examples should make clear the undesirable effects of the loss.

    Note the misalignment:

    Code:
    $ htop
    
      1  [|||||||||||||||                         30.3%]   Tasks: 131, 0 thr; 5 running
      2  [|||||||||||||||||                       37.4%]   Load average: 1.52 1.14 1.02
      3  [|||||||||||||||                         30.8%]   Uptime: 17:45:22
      4  [|||||||||||||||                         30.3%]
      Mem[|||||||||||||                     3.49G/15.8G]
      Swp[                                     0K/8.00G]
    
      PID USER      PRI  NI  VIRT   RES S CPU% MEM%   TIME+  Command
        0 root      -16   0     0  8096 S  0.1  0.0  5:36.36 kernel
        1 root       20   0  5412   720 S  0.0  0.0  0:00.22 /sbin/init --
      476 root       20   0 20028  4596 S  0.0  0.0  0:00.25 /usr/sbin/wpa_supplicant -s -B -i wlan0 -c /etc/wpa_su
      488 root       52   0 10620  2096 S  0.0  0.0  0:00.00 dhclient: wlan0 [priv]
      489 _dhcp      20   0 10620  2332 S  0.0  0.0  0:00.00 dhclient: wlan0
      603 root      -44 -44 25072  5084 S  0.0  0.0  0:04.19 /usr/local/sbin/webcamd -i 0 -d ugen0.7 -B -U webcamd
      710 root       20   0 12712  1648 S  0.0  0.0  0:46.83 /usr/sbin/moused -A 1.5 -p /dev/ums0 -t auto -I /var/r
      775 root       20   0  9544  5280 S  0.0  0.0  0:00.07 /sbin/devd
      903 root       20   0 10496  1996 S  0.0  0.0  0:01.58 /usr/sbin/syslogd -c -ss
    1055 root       52   0 12628  1628 S  0.0  0.0  0:00.00 /usr/sbin/iscsid
    1075 root       20   0 10452  2256 S  0.0  0.0  0:00.10 /usr/sbin/rpcbind
    1077 root       20   0  272M  3936 S  0.0  0.0  0:00.06 /usr/sbin/rpc.statd
    1085 root       52   0 16624  3864 S  0.0  0.0  0:00.10 /usr/sbin/rpc.lockd
    1099 messagebu  20   0 13124  3668 S  0.0  0.0  0:04.11 /usr/local/bin/dbus-daemon --system
    1145 root       52   0 20020  2296 S  0.0  0.0  0:00.00 /usr/local/sbin/jobd
    1149 _ntp       20 -20 21344  3640 S  0.0  0.0  0:00.11 ntpd: ntp engine
    1150 _ntp       52   0 21344  3772 S  0.0  0.0  0:00.00 ntpd: dns engine
    1151 root       20 -20 21344  3512 S  0.0  0.0  0:00.01 /usr/local/sbin/ntpd -s -f /usr/local/etc/ntpd.conf
    1154 root       20   0 19852  2340 S  0.0  0.0  0:53.79 /usr/local/sbin/powerd++
    1184 root       52   0 10456  1672 S  0.0  0.0  0:00.00 daemon: /usr/local/bin/sysadm-server[1186]
    1186 root       28   0  123M 19244 R 19.7  0.1 16:42.87 /usr/local/bin/sysadm-binary
    1195 root       52   0 13172  1972 S  0.0  0.0  0:00.01 /bin/sh /usr/local/sbin/PCDMd
    1203 root       20   0 12712  1788 S  0.0  0.0  0:00.00 /usr/sbin/moused -A 1.5 -p /dev/psm0 -t auto
    $ 
    Code:
    $ kldstat
    Id Refs Address  Size  Name
    1  159 0xffffffff80200000 1ddea90  kernel
    2  1 0xffffffff81fe0000 30af90  zfs.ko
    3  2 0xffffffff822eb000 ac98  opensolaris.ko
    4  1 0xffffffff822f6000 21890  geom_eli.ko
    5  1 0xffffffff82318000 23698  geom_journal.ko
    6  1 0xffffffff8233c000 23a68  geom_mirror.ko
    7  1 0xffffffff82360000 128b8  tmpfs.ko
    8  1 0xffffffff82373000 b300  aesni.ko
    9  1 0xffffffff82bfa000 c00f  linprocfs.ko
    10  4 0xffffffff82c07000 7d05  linux_common.ko
    11  1 0xffffffff82c0f000 12de8c  i915kms.ko
    12  1 0xffffffff82d3d000 813bc  drm.ko
    13  3 0xffffffff82dbf000 31b06  linuxkpi.ko
    14  2 0xffffffff82df1000 69aa  debugfs.ko
    15  2 0xffffffff82df8000 4478  libiconv.ko
    16  1 0xffffffff82dfd000 1e0f  libmchain.ko
    17  1 0xffffffff82dff000 7ac  msdosfs_iconv.ko
    18  1 0xffffffff82e00000 33a99  if_bwn.ko
    19  1 0xffffffff82e34000 80bb  siba_bwn.ko
    20  1 0xffffffff82e3d000 1fd6c  if_bwi.ko
    21  1 0xffffffff82e5d000 2707  runfw.ko
    22  1 0xffffffff82e60000 1919e  if_iwm.ko
    23  1 0xffffffff82e7a000 1209d9  iwm7265fw.ko
    24  1 0xffffffff82f9b000 83f0  cuse.ko
    25  1 0xffffffff82fa4000 6db5  sem.ko
    26  1 0xffffffff82fab000 8ee9  geom_uzip.ko
    27  1 0xffffffff82fb4000 57e2  fdescfs.ko
    28  1 0xffffffff82fba000 2e55b  iwn4965fw.ko
    29  1 0xffffffff82fe9000 52d7f  iwn1000fw.ko
    30  1 0xffffffff8303c000 539ee  iwn5000fw.ko
    31  1 0xffffffff83090000 52d0f  iwn5150fw.ko
    32  1 0xffffffff830e3000 6f6e6  iwn6000fw.ko
    33  1 0xffffffff83153000 a5ccf  iwn6000g2afw.ko
    34  1 0xffffffff831f9000 a652b  iwn6000g2bfw.ko
    35  1 0xffffffff832a0000 73230  iwn6050fw.ko
    36  1 0xffffffff83314000 372d  acpi_video.ko
    37  1 0xffffffff83318000 e264  fuse.ko
    38  1 0xffffffff83327000 44cc  ums.ko
    39  1 0xffffffff8332c000 29c0  uhid.ko
    40  1 0xffffffff8332f000 4fa7  ng_ubt.ko
    41  5 0xffffffff83334000 bf21  netgraph.ko
    42  1 0xffffffff83340000 a58f  ng_hci.ko
    43  3 0xffffffff8334b000 107e  ng_bluetooth.ko
    44  1 0xffffffff8334d000 d57d  ng_l2cap.ko
    45  1 0xffffffff8335b000 1b0ee  ng_btsocket.ko
    46  1 0xffffffff83377000 393b  ng_socket.ko
    47  1 0xffffffff8337b000 2343a  ipfw.ko
    48  1 0xffffffff8339f000 3d771  linux.ko
    49  1 0xffffffff833dd000 39344  linux64.ko
    50  1 0xffffffff83417000 e967  iscsi.ko
    51  1 0xffffffff83426000 81e6  autofs.ko
    $ 
    Whilst those two examples may be viewed as cosmetic, there is – I believe – a real problem when white space is lost from some other types of code (where leading white spaces, indents, are critical).

    http://forums.macrumors.com/posts/20495888 reminds me that this XenForo bug was discussed in 2014, around the time of migration of MacRumors Forums.

    I vaguely recall some comment that the altering of code was intended to reduce a risk of some sort. Is that so? (@arn can you recall the conversation?) Whatever the intention, it's technically undesirable to alter code in this way.

    Thanks for your consideration …
     
  2. Mike

    Mike XenForo Developer Staff Member

    Can you attach the original text in a file so we can see what it was and reproduce it from that? Can you also comment as to whether you're using the insert code dialog or just pasting into the editor?
     
  3. grahamperrin

    grahamperrin Member

    With the insert code dialogue, general code:

    Code:
       i) one
      ii) two
    iii) three
      iv) four
       v) five
      vi) six
    vii) seven
    viii) eight
      ix) nine
       x) ten
    Pasted to the editing field, then I manually added the opening and /closing CODE tags:

    Code:
      i) one
      ii) two
     iii) three
      iv) four
      v) five
      vi) six
     vii) seven
    viii) eight
      ix) nine
      x) ten
     

    Attached Files:

  4. Mike

    Mike XenForo Developer Staff Member

    There were a few different bugs here. It seems that Firefox had an issue with pasting while Chrome appeared to handle that without issue. There was a bug with a single leading white space character that was browser independent.

    I believe these are all fixed now. I've just rolled the fixes out here if they are any cases you want to test (the fix isn't retroactive).
     
    SneakyDave, grahamperrin and eva2000 like this.
  5. grahamperrin

    grahamperrin Member

  6. grahamperrin

    grahamperrin Member

    Second test with Firefox, a click on More Options… then paste to the reply field,

    Code:
      i) one
      ii) two
    iii) three
      iv) four
       v) five
      vi) six
    vii) seven
    viii) eight
      ix) nine
       x) ten
    – then Preview… then still in the rich editor, manually wrap CODE tags around what was pasted, then again Preview… and finally Reply to Thread
     
    Last edited: Aug 30, 2016
  7. grahamperrin

    grahamperrin Member

    … and I guess that what's above exemplifies an issue with Firefox pasting to the rich text editor.

    Third test, switching away from that editor, using the same Firefox to paste –

    Code:
       i) one
      ii) two
     iii) three
      iv) four
       v) five
      vi) six
     vii) seven
    viii) eight
      ix) nine
       x) ten
    – then manually wrap, then More Options… (which switches back to rich edition) then Preview… and finally Reply to Thread
     
  8. Mike

    Mike XenForo Developer Staff Member

    Looks like there might still be a case, though I did test Firefox explicitly. Was that broken on preview for you?
     
  9. grahamperrin

    grahamperrin Member

    Test 2: yes, broken on preview and (conscientiously) in normal circumstances I might have revisited the original text to repeat a copy and paste. For test purposes I left the breakage as is.

    My gut tells me that it's unreasonable to expect fidelity when (a) a paste of code is followed by (b) manual markup if both (a) and (b) are in the rich text editor and if the user ignores (or is unaware of) the insert code feature.

    Give me five, I'll perform a comparable test with Chromium.
     
  10. grahamperrin

    grahamperrin Member

    Test 4

    Comparable with test 2, but using Chromium in lieu of Firefox. Ignoring the insert code option, and adding the CODE tags whilst in the rich text environment. Also ignoring More Options… (ignoring the option to preview) I lazily click Post Reply

    Code:
      i) one
      ii) two
    iii) three
      iv) four
       v) five
      vi) six
    vii) seven
    viii) eight
      ix) nine
       x) ten
     
  11. Mike

    Mike XenForo Developer Staff Member

    Hmm, I actually specifically tested Chrome and Firefox pasting directly in the RTE, though it's possible there might be some differences in the exact approach in how we edited the output. I'll do some more testing.
     
  12. grahamperrin

    grahamperrin Member

    Test 5

    Chromium (51.0.2704.106 (64-bit) on TrueOS Desktop) and here I switch away from rich text before pasting –

    Code:
       i) one
      ii) two
     iii) three
      iv) four
       v) five
      vi) six
     vii) seven
    viii) eight
      ix) nine
       x) ten
    – then manually wrapping in CODE tags and posting the reply without taking More Options…

    That's very thorough of you :) more than I expect, to be honest (given the availability of the insert code feature).

    If it helps: Firefox on this OS is 47.0.1.
     
  13. Mike

    Mike XenForo Developer Staff Member

    Unfortunately, I'm struggling to reproduce this. I've tested on Windows and Mac, the latter being the closest thing I have available to a BSD distribution. This appears to work as expected in both place. This might be an OS-specific formatting issue.

    Can anyone else confirm this with 1.5.10a/here? (You shouldn't need to post -- previewing the results should be fine.)
     
  14. Snog

    Snog Well-Known Member

    Using Firefox 48.0 (Linux Mint) it posts fine using the insert selection in the editor menu. But if you hand type the code /code bbcode and paste between them the whitespace is lost.

    Same thing with Chrome 53.0.2785.101.
     
    Last edited: Sep 9, 2016
    grahamperrin likes this.
  15. Mike

    Mike XenForo Developer Staff Member

    I have managed to reproduce another case where this was failing, so I think this should be fixed now. I just rolled out the fix here if anyone wants to confirm.
     
    grahamperrin and Snog like this.
  16. Snog

    Snog Well-Known Member

    Works fine with Firefox here.
     
    grahamperrin likes this.
  17. grahamperrin

    grahamperrin Member

    Works for me now with the following browsers on TrueOS Desktop beta:
    • Chromium 52.0.2743.116
    • Firefox 47.0.1
    • Qupzilla (Mozilla/5.0 (X11; FreeBSD) AppleWebKit/538.1 (KHTML, like Gecko) QupZilla/1.8.9 Safari/538.1)
    • Web 3.16.3
    $ date ; freebsd-version ; uname -a
    Fri 16 Sep 2016 18:57:09 BST
    12.0-CURRENT
    FreeBSD momh167-gjp4-hpelitebook850g2-trueos.university.brighton.ac.uk 12.0-CURRENT FreeBSD 12.0-CURRENT #8 a212210(drm-next-4.7): Tue Sep 6 12:20:35 UTC 2016 root@gauntlet:/usr/obj/usr/src/sys/GENERIC amd64
    $


    Excellent! Thanks again.
     

Share This Page