Forum

Thread tagged as: Problem

Zero Width Space Characters

Hi there,

I'm having an issue, where a client is pasting in text from Word -> TextEdit -> Perch text field yet this strange character seems to be sneaking into the field and because I'm generating a slug from the title, the url is giving me a 404 error. I only found it it was called a 'Zero Width Space' by pasting it into some converter online. I'm wondering if there is a good way to strip these out, I thought replace might be the short term answer but I've never come across this issue before.

I've attached my template and diagnostics below, hopefully they can shed some light (and not reveal how messy my code is!).

Thanks!

Template:

<article class="h-entry">
    <h1>
        <a href="<perch:content id="slug" type="slug" for="postDateTime_year postDateTime_month postDateTime_day postTitle" suppress="true" />" rel="bookmark" class="p-name">
            <perch:content id="postTitle" type="text" label="Title" required="true" order="1" title="true" />
        </a>
    </h1>
    <perch:if exists="image">
        <div class="image">
            <img src="<perch:content id="image" type="image" width="360" height="225" crop="true" />"
                 srcset="
                    <perch:content id="image" type="image" width="360" height="225" crop="true" /> 360w,
                    <perch:content id="image" type="image" width="640" height="400" crop="true" /> 640w,
                    <perch:content id="image" type="image" label="Image" width="844" height="528" crop="true" order="4" help="Upload or select an image, minimum size: 860px wide." /> 844w"
                 sizes="(min-width: 40em) 75vw, 100vw"
                 alt="<perch:content id="postTitle" type="text" />" 
                />
        </div>
    </perch:if>
    <div class="description e-content">
        <perch:template path="content/buildable_inner_page.html" />
    </div>
    <hr>
    <div class="meta">
        <time class="dt-published" datetime="<perch:content id="postDateTime" type="date" label="Date" time="true" format="Y-m-d H:i:s" divider-before="Meta information" />">
            <perch:content id="postDateTime" type="date" time="true" format="%d %B %Y" required="true" />
        </time>
        <perch:related id="author" collection="Authors" label="Author(s)">
            by <span class="p-author h-card"><perch:content id="first_name" type="text" /> <perch:content id="last_name" type="hidden" /></span>
        </perch:related>
    </div>
</article>

<perch:content id="excerpt" type="textarea" label="Excerpt" markdown="true" order="3" suppress="true" size="s" />
<perch:content id="image" type="image" width="282" height="176" crop="true" suppress="true" />
<perch:template path="content/_content_seo.html" />

Diagnostics:

SUMMARY INFORMATION

Perch Runway: 2.8.13, PHP: 5.6.12, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 3c688b6bbc30d36af3ac34fdd4b7b5b787fe5555 $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (2.8.13), assets (2.8.13), categories (2.8.13), perch_forms (1.8.3)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_forms' );
PERCH_LOGINPATH: /perch
PERCH_PATH: /home/site/public_html/perch
PERCH_CORE: /home/site/public_html/perch/core
PERCH_RESFILEPATH: /home/site/public_html/perch/resources
Image manipulation: GD Imagick
PHP limits: Max upload 256M, Max POST 256M, Memory: 256M, Total max file upload: 256M
Resource folder writeable: Yes
DOCUMENT_ROOT: /home/site/public_html
HTTP_HOST: site.com
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Mark Greenwood

Mark Greenwood 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

It's generally always best to avoid Word if possible. It does fill text with all sorts of random junk. In the 18 or so years I've been building content management systems, I've not found a reliable way to protect against it.

Yeah, I avoid it as best I can, especially out of date versions. I think that's the best way to go, too. As it's only the title field it could be typed rather than a lazy paste, anyway.

Cheers.