CodeMyst / CodeMyst/pastemyst

[bug] Unlisted language prevents pasties from being edited

Open
#440 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
D
Stars
126
Forks
10
PR merge metrics
No merged PRs in 30d

Description

**describe the bug**
Language autodetection detects the language not listed in the language dropdown (when creating/editing pasty)

For example, the following C code:

```c
#include

int main() {
printf("Hello, world!\n");
return 0;
}
```
is detected as `Yacc` (Example: https://paste.myst.rs/h1twkz21) and will prevent the language of the pasty being changed and prevents the content from being saved.

However, everything works as expected when the pasty is explicitly set to be the C programming language.

**errors**

Upon initially loading the edit page of the problematic paste, The following error will occur within the console:
```
Uncaught (in promise) TypeError: can't access property "value", that is null
setValue https://paste.myst.rs/static/scripts/components/dropdown.js:171
resetValue https://paste.myst.rs/static/scripts/components/dropdown.js:201
setupLanguageDropdown https://paste.myst.rs/static/scripts/components/pastyEditor.js:225
initEditors https://paste.myst.rs/static/scripts/components/pastyEditor.js:37
https://paste.myst.rs/static/scripts/pages/editPaste.js?v=2.8.4:7
EventListener.handleEvent* https://paste.myst.rs/static/scripts/pages/editPaste.js?v=2.8.4:5
```

And when attempting to change the value of the language dropdown, the following will occur:
```
Uncaught TypeError: can't access property "checked", this.checked is null
setValue https://paste.myst.rs/static/scripts/components/dropdown.js:176
updateValue https://paste.myst.rs/static/scripts/components/dropdown.js:160
addEventListeners https://paste.myst.rs/static/scripts/components/dropdown.js:26
addEventListeners https://paste.myst.rs/static/scripts/components/dropdown.js:20
Dropdown https://paste.myst.rs/static/scripts/components/dropdown.js:13
setupLanguageDropdown https://paste.myst.rs/static/scripts/components/pastyEditor.js:223
initEditors https://paste.myst.rs/static/scripts/components/pastyEditor.js:37
https://paste.myst.rs/static/scripts/pages/editPaste.js?v=2.8.4:7
EventListener.handleEvent* https://paste.myst.rs/static/scripts/pages/editPaste.js?v=2.8.4:5
```

No error will occur when the save button is pressed.

**to reproduce**
steps to reproduce the behavior:
1. Log in
2. Create a paste (can use the code above as an example)
3. Try to edit it
4. Can't change the language of the pasty nor save the edits to the text content (Nothing happens after pressing "Save")

**expected behavior**
The language of the pasty is changed, and the changes to the content are saved.

**screenshots**
if applicable, add screenshots to help explain your problem.

**device and browser:**
- os: Linux
- browser: Firefox
- browser version: 144.0 (64-bit)

**additional context**
Another problematic paste as an example: https://paste.myst.rs/gorxhjf7

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.