#1846·PrivateBin

defaultformatter config option ignored on new paste — hardcoded 'plaintext' in Controller.newPaste()

Author: drako86Created May 15, 2026Updated May 17, 2026
LabelsbugUI/UX

Bug description

The defaultformatter option in conf.php is ignored when creating a new paste. The formatter select always defaults to plaintext regardless of the configured value.

Expected behavior

Setting defaultformatter = "markdown" in conf.php should pre-select Markdown in the formatter dropdown when the user opens a new paste.

Actual behavior

The formatter dropdown always shows plaintext selected, even when defaultformatter = "markdown" is correctly set and confirmed in the server-side HTML (<option value="markdown" selected="selected">).

Root cause

In js/privatebin.js, Controller.newPaste() hardcodes the formatter to plaintext:

javascript
// js/privatebin.js ~line 5813
me.newPaste = function()
{
    // ...
    PasteViewer.setFormat('plaintext');  // ← ignores defaultformatter
    TopNav.setFormat('plaintext');       // ← ignores defaultformatter
    // ...
}

These two calls override the selected="selected" attribute already correctly rendered in the HTML by the PHP backend.

Fix

Replace the hardcoded 'plaintext' with Model.getFormatDefault(), which reads the current value of #pasteFormatter (already set correctly by the server-side template):

javascript
PasteViewer.setFormat(Model.getFormatDefault());
TopNav.setFormat(Model.getFormatDefault());

Note: after patching privatebin.js the SRI hash in Configuration.php must be updated accordingly.

Environment

  • PrivateBin version: 2.0.4
  • Image: privatebin/nginx-fpm-alpine:latest
  • Browser: tested on Firefox and Chrome (multiple sessions, cleared cache)
  • conf.php setting: defaultformatter = "markdown"
  • Server-side HTML confirmed correct (selected="selected" on markdown option)
  • No localStorage or sessionStorage interference confirmed via DevTools

Steps to reproduce

  1. Set defaultformatter = "markdown" in conf.php
  2. Open a new PrivateBin instance in the browser
  3. Observe the formatter dropdown shows "Plain Text" instead of "Markdown"
  4. Inspect the raw HTML: <option value="markdown" selected="selected"> is correct
  5. Inspect via DevTools console:
    • document.querySelector('#pasteFormatter option[selected]').value"markdown"
    • document.getElementById('pasteFormatter').value"plaintext"