mirror of
https://github.com/flarum/core.git
synced 2025-07-17 14:51:19 +02:00
Trim spaces in getPlainContent, prevent images from loading
fixes #834 closes #963
This commit is contained in:
6
js/forum/dist/app.js
vendored
6
js/forum/dist/app.js
vendored
@@ -31481,11 +31481,13 @@ System.register('flarum/utils/string', [], function (_export, _context) {
|
|||||||
_export('slug', slug);
|
_export('slug', slug);
|
||||||
|
|
||||||
function getPlainContent(string) {
|
function getPlainContent(string) {
|
||||||
var dom = $('<div/>').html(string.replace(/(<\/p>|<br>)/g, '$1 '));
|
var html = string.replace(/(<\/p>|<br>)/g, '$1 ').replace(/<img\b[^>]*>/ig, ' ');
|
||||||
|
|
||||||
|
var dom = $('<div/>').html(html);
|
||||||
|
|
||||||
dom.find(getPlainContent.removeSelectors.join(',')).remove();
|
dom.find(getPlainContent.removeSelectors.join(',')).remove();
|
||||||
|
|
||||||
return dom.text();
|
return dom.text().replace(/\s+/g, ' ').trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -34,11 +34,15 @@ export function slug(string) {
|
|||||||
* @return {String}
|
* @return {String}
|
||||||
*/
|
*/
|
||||||
export function getPlainContent(string) {
|
export function getPlainContent(string) {
|
||||||
const dom = $('<div/>').html(string.replace(/(<\/p>|<br>)/g, '$1 '));
|
const html = string
|
||||||
|
.replace(/(<\/p>|<br>)/g, '$1 ')
|
||||||
|
.replace(/<img\b[^>]*>/ig, ' ');
|
||||||
|
|
||||||
|
const dom = $('<div/>').html(html);
|
||||||
|
|
||||||
dom.find(getPlainContent.removeSelectors.join(',')).remove();
|
dom.find(getPlainContent.removeSelectors.join(',')).remove();
|
||||||
|
|
||||||
return dom.text();
|
return dom.text().replace(/\s+/g, ' ').trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user