Bug 27694

Summary: News tool editor (codemirror) automatically converts HTML entities
Product: Koha Reporter: Lucas Gass (lukeg) <lucas>
Component: ToolsAssignee: Lucas Gass (lukeg) <lucas>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: trivial    
Priority: P5 - low CC: dcook, fridolin.somers, rhouk
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
21.05.00
Circulation function:
Attachments: Bug 27694: use HTML filtering on News Tool textarea
Bug 27694: use HTML filtering on News Tool textarea
Bug 27694: use HTML filtering on News Tool textarea

Description Lucas Gass (lukeg) 2021-02-12 15:55:54 UTC
When using CodeMirror in the Koha News tool the editor automatically converts HTML entities which can be problematic.  


For example:

<option value="(itype:DVD and loc:*NEW) AND NOT index-term-genre:&quot;television&quot;">Movies</option>

Gets converted to:

<option value="(itype:DVD and loc:*NEW) AND NOT index-term-genre:"television"">Movies</option>
Comment 1 Lucas Gass (lukeg) 2021-02-12 16:01:48 UTC
Created attachment 116839 [details] [review]
Bug 27694: use HTML filtering on News Tool textarea

To test:
1. Add some HTML enties to your codemirror in the News Tool. Example: <option value="(itype:DVD and loc:*NEW) AND NOT index-term-genre:&quot;television&quot;">Movies</option>
2. Save and re-eneter the tool, the HTML entites have been converted
3. Apply patch
4. Try again, HTML entities should not be converted
Comment 2 ByWater Sandboxes 2021-02-16 14:49:49 UTC
Created attachment 116926 [details] [review]
Bug 27694: use HTML filtering on News Tool textarea

To test:
1. Add some HTML enties to your codemirror in the News Tool. Example: <option value="(itype:DVD and loc:*NEW) AND NOT index-term-genre:&quot;television&quot;">Movies</option>
2. Save and re-eneter the tool, the HTML entites have been converted
3. Apply patch
4. Try again, HTML entities should not be converted

Signed-off-by: Ron Houk <rhouk@ottumwapubliclibrary.org>
Comment 3 Katrin Fischer 2021-02-17 20:15:37 UTC
This appears to work, but is it expected that you can't use the source view of the visual editor to enter <option value="(itype:DVD and loc:*NEW) AND NOT index-term-genre:&quot;television&quot;">Movies</option> ? It only leaves "Movies" and that's scary. 

Does it mean opening in the wrong editor and saving, you'll completely destroy things?
Comment 4 Katrin Fischer 2021-02-17 20:18:12 UTC
(In reply to Katrin Fischer from comment #3)
> This appears to work, but is it expected that you can't use the source view
> of the visual editor to enter <option value="(itype:DVD and loc:*NEW) AND
> NOT index-term-genre:&quot;television&quot;">Movies</option> ? It only
> leaves "Movies" and that's scary. 
> 
> Does it mean opening in the wrong editor and saving, you'll completely
> destroy things?

Ok. it only destroy entries if it doesn't like your HTML. Adding the surrounding select make it stay ok.
Comment 5 Katrin Fischer 2021-02-17 20:19:52 UTC
Created attachment 116966 [details] [review]
Bug 27694: use HTML filtering on News Tool textarea

To test:
1. Add some HTML enties to your codemirror in the News Tool. Example: <option value="(itype:DVD and loc:*NEW) AND NOT index-term-genre:&quot;television&quot;">Movies</option>
2. Save and re-eneter the tool, the HTML entites have been converted
3. Apply patch
4. Try again, HTML entities should not be converted

Signed-off-by: Ron Houk <rhouk@ottumwapubliclibrary.org>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 6 Jonathan Druart 2021-02-18 11:05:59 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 7 Fridolin Somers 2021-02-22 10:21:50 UTC
when using "Edit with text editor", html is escaped twice :
&quot; > &amp;quot;

Is this the expected behavior ?