Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/fulltextsearch.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/Model
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2017-12-29 14:19:50 +0300
committerMaxence Lange <maxence@artificial-owl.com>2017-12-29 14:19:50 +0300
commit49d6bd01f3ff65401932634f7a1386fd754e8fd8 (patch)
treedafa2de2a7f84b99e5ca950be76891f507132b7d /lib/Model
parenteae4aa417ebcc13a526620b32fdc71ab2554967b (diff)
cleaning excerpt
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/Model')
-rw-r--r--lib/Model/IndexDocument.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Model/IndexDocument.php b/lib/Model/IndexDocument.php
index 00cdfdb..01fabcb 100644
--- a/lib/Model/IndexDocument.php
+++ b/lib/Model/IndexDocument.php
@@ -302,6 +302,8 @@ class IndexDocument implements \JsonSerializable {
* @return $this
*/
public function setExcerpts($excerpts) {
+ $excerpts = array_map([$this, 'cleanExcerpt'], $excerpts);
+
$this->excerpts = $excerpts;
return $this;
@@ -318,9 +320,24 @@ class IndexDocument implements \JsonSerializable {
* @param string $excerpt
*/
public function addExcerpt($excerpt) {
+ $excerpt = $this->cleanExcerpt($excerpt);
+
$this->excerpts[] = $excerpt;
}
+ /**
+ * @param $excerpt
+ *
+ * @return mixed
+ */
+ public function cleanExcerpt($excerpt) {
+ $excerpt = str_replace("\\n", ' ', $excerpt);
+ $excerpt = str_replace("\\r", ' ', $excerpt);
+ $excerpt = str_replace("\n", ' ', $excerpt);
+ $excerpt = str_replace("\r", ' ', $excerpt);
+
+ return $excerpt;
+ }
/**
* @param string $score