`defaultformatter` config option is ignored when starting a new paste
Describe the problem/question
The defaultformatter option in cfg/conf.php is correctly rendered server-side (the matching <option> gets selected="selected" in the initial HTML), but it gets overridden by client-side JavaScript as soon as the page finishes loading (or when clicking "New").
Steps to reproduce
- Set
defaultformatter = "markdown"incfg/conf.php(withmarkdownpresent in[formatter_options]). - Restart php-fpm / clear any opcache to make sure the new config is loaded.
- Load the instance's homepage (a fresh "new paste" view).
- Inspect the format dropdown.
What happens
- The raw HTML (verified via
curl) correctly shows<option value="markdown" selected="selected">. - However, after the page's JS runs,
document.getElementById('pasteFormatter').valuereturns"plaintext", and the visible dropdown shows "Plain Text" instead of "Markdown".
What should happen
The dropdown should stay on the configured defaultformatter value ("markdown" in this case) after the page finishes loading.
Root cause (found while debugging)
In js/privatebin.js, Controller.newPaste() contains:
```js // reset format PasteViewer.setFormat('plaintext'); TopNav.setFormat('plaintext'); ```
This hardcodes 'plaintext' instead of reading the configured default via Model.getFormatDefault() (which is used correctly elsewhere, e.g. around line 2918: format = Model.getFormatDefault() || format;).
Since Controller.newPaste() runs both on initial page load and when clicking "New", any defaultformatter other than "plaintext" is effectively unusable.
Additional information
- Tested on a self-hosted
Source: PrivateBin/PrivateBin