Bug 40831 - Attempting to save a notice with html present and the html checkbox not selected should warn
Summary: Attempting to save a notice with html present and the html checkbox not selec...
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Tools (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-09-17 21:18 UTC by Lisette Scheer
Modified: 2025-09-17 23:46 UTC (History)
2 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lisette Scheer 2025-09-17 21:18:06 UTC
It would be helpful if after editing a notice, when saving it checked that if there's html in the notice, the html box is selected and warn the user.
Comment 1 David Cook 2025-09-17 23:46:02 UTC
This is an interesting idea! 

In theory, we could use Javascript for this. For instance:

<script>
let parser = new DOMParser();
let doc = parser.parseFromString('cool beans','text/html');
console.log(doc.documentElement.textContent);
let doc2 = parser.parseFromString('<b>awesome</b>','text/html');
console.log(doc2.documentElement.textContent);
</script>

The output should be like this:
"cool beans"
"awesome"

If you compare the output strings against the input strings, the first one should be identical while the second one won't match, which indicates that there was HTML that was parsed in the string.

--

Maybe there's better ways of doing it, but that way jumped out to me. A person could try to use regex but I think that would be a nightmare.

Of course, if the string didn't contain HTML but there was something that was interpreted as HTML but wasn't HTML then you could get a false positive...

So it would be important to be able to bypass the warning for sure.