Forum

Thread tagged as: Problem, Runway, Blog

URL Encode Blog Post Slug

If a blog post title includes a '=' symbol, the blog post returns a 404 error, I assume because the slug isn't being URL encoded?

I'm not using a custom slug, but is there any way to ensure that if the author enters an invalid character into the post title then to encode the slug?

Diagnostics:

Perch Runway: 3.0.4
Production mode: Development (1)
Installed apps: content (3.0.4), assets (3.0.4), categories (3.0.4), perch_blog (5.5.1), perch_forms (1.9)
DB driver: PDO
DB tables: perch2_backup_plans (1), perch2_backup_resources (10), perch2_backup_runs (9), perch2_blog_authors (1), perch2_blog_comments (0), perch2_blog_index (489), perch2_blog_posts (17), perch2_blog_posts_to_tags (0), perch2_blog_sections (1), perch2_blog_tags (0), perch2_blogs (1), perch2_categories (1), perch2_category_counts (1), perch2_category_sets (1), perch2_collection_index (755), perch2_collection_items (132), perch2_collection_revisions (54), perch2_collections (3), perch2_content_index (1006), perch2_content_items (167), perch2_content_locks (0), perch2_content_regions (16), perch2_forms (3), perch2_forms_responses (4), perch2_menu_items (12), perch2_navigation (0), perch2_navigation_pages (0), perch2_page_routes (7), perch2_page_templates (33), perch2_pages (13), perch2_resource_log (134), perch2_resource_tags (3), perch2_resources (64), perch2_resources_to_tags (6), perch2_scheduled_tasks (2), perch2_settings (30), perch2_user_passwords (0), perch2_user_privileges (40), perch2_user_role_privileges (20), perch2_user_roles (2), perch2_users (3)
Users: 3
App runtimes:
<?php
    $apps_list = array(
        'perch_blog',
        'perch_forms'
    );
Scheduled tasks for perch_blog: delete_spam_comments (1440 mins)
Scheduled tasks for Backup: plan_1 (10 mins)
Editor plug-ins:
H1: 895ce35e7e6c7f92b9c206ad83b83a05
L1: cd7da0f335aa34ac220f6c163fa316aa
F1: 0c66c2e1f82f9e0b7617b2cb8270f2c7
headerColour: #ffffff
content_singlePageEdit: 1
siteURL: /
hideBranding: 1
content_collapseList: 1
lang: en-gb
update_2.8.34: done
perch_blog_site_name:
headerScheme: light
update_runway_2.8.34: done
latest_version:
dashboard: 0
hide_pwd_reset: 0
content_hideNonEditableRegions: 0
content_frontend_edit: 0
perch_blog_update: 5.0.1
perch_blog_post_url: /news/{postSlug}
perch_blog_slug_format: {postTitle}
perch_blog_akismet_key:
perch_blog_max_spam_days: 30
perch_blog_comment_notify: 0
update_runway_3.0: done
siteOffline: 0
update_runway_3.0.1: done
logoPath: /admin/resources/logo.svg
update_runway_3.0.2: done
helpURL: creativemonster.co.uk
on_sale_version: 3.0.4
update_runway_3.0.4: done
content_skip_region_list: 0
PERCH_DEVELOPMENT: 10
PERCH_STAGING: 50
PERCH_PRODUCTION: 100
PERCH_SITEPATH: /Users/Toby/Sites/catch
PERCH_SCHEDULE_SECRET: 1bK6mcBYEmBNPksH
PERCH_DB_USERNAME: root
PERCH_DB_DATABASE: perch_catch_local
PERCH_DB_SERVER: localhost
PERCH_DB_PREFIX: perch2_
PERCH_EMAIL_FROM: info@catchgroup.com
PERCH_EMAIL_FROM_NAME: Catch Resource Management
PERCH_LOGINPATH: /admin
PERCH_PATH: /Users/Toby/Sites/catch/admin
PERCH_CORE: /Users/Toby/Sites/catch/admin/core
PERCH_RESFILEPATH: /Users/Toby/Sites/catch/admin/resources
PERCH_RESPATH: /admin/resources
PERCH_HTML5: 1
PERCH_TZ: UTC
PERCH_YOUTUBE_API_KEY: AIzaSyB_oQZ-2loHP9uftDX2obdv9beODmpNzao
PERCH_PRODUCTION_MODE: 1
PERCH_RUNWAY: 1
PERCH_ERROR_MODE: DIE
PERCH_DATE_LONG: %d %B %Y
PERCH_DATE_SHORT: %d %b %Y
PERCH_TIME_SHORT: %H:%M
PERCH_TIME_LONG: %H:%M:%S
PERCH_RUNWAY_ROUTED:
PERCH_STRONG_PASSWORDS:
PERCH_ASSET_VERSION: ed79f7a54b300ef2b1e6
PERCH_DEBUG:
PERCH_PREVIEW_ARG: preview
PERCH_TEMPLATE_PATH: /Users/Toby/Sites/catch/admin/templates
PERCH_TEMPLATE_FILTERS:
PERCH_DEFAULT_DOC: index.php
PERCH_DEFAULT_EXT: .php
PERCH_XHTML_MARKUP:
PERCH_RWD: 1
PERCH_HTML_ENTITIES:
PERCH_SSL:
PERCH_STRIPSLASHES:
PERCH_PROGRESSIVE_FLUSH: 1
PERCH_PARANOID:
PERCH_FORCE_SECURE_COOKIES:
PERCH_DEFAULT_BUCKET: default
PERCH_TRANSLATION_ASSIST:
PERCH_PASSWORD_MIN_LENGTH: 6
PERCH_MAX_FAILED_LOGINS: 10
PERCH_AUTH_LOCKOUT_DURATION: 1 HOUR
PERCH_VERIFY_UPLOADS:
PERCH_PRIV_ASSIST:
PERCH_AUTH_PLUGIN:
PERCH_DB_CHARSET: utf8
PERCH_DB_PORT:
PERCH_DB_SOCKET:
PERCH_APPS_EDITOR_PLUGIN: markitup
PERCH_APPS_EDITOR_MARKUP_LANGUAGE: markdown
Hosting settings

PHP: 7.0.13
Zend: 3.0.0
OS: Darwin
SAPI: cgi-fcgi
Safe mode: not detected
MySQL client: mysqlnd 5.0.12-dev - 20150407 - $Id: 241ae00989d1995ffcbbf63d579943635faf9972 $
MySQL server: 5.6.34
Free disk space: 29.12 GB
Extensions: Core, date, libxml, openssl, pcre, sqlite3, zlib, bcmath, bz2, calendar, ctype, curl, dom, hash, fileinfo, filter, ftp, gd, SPL, iconv, intl, json, ldap, mbstring, session, standard, mysqlnd, PDO, pdo_mysql, pdo_sqlite, Phar, posix, readline, Reflection, mysqli, SimpleXML, soap, sockets, exif, tokenizer, wddx, xml, xmlreader, xmlwriter, xsl, zip, cgi-fcgi, imap, gettext, mcrypt, pgsql, pdo_pgsql, igbinary, memcached
GD: Yes
ImageMagick: No
PHP max upload size: 32M
PHP max form post size: 32M
PHP memory limit: 128M
Total max uploadable file size: 32M
Resource folder writeable: Yes
Session timeout: 24 minutes
Native JSON: Yes
Filter functions: Yes
Transliteration functions: Yes
PHP_FCGI_CHILDREN: 4
PWD: /Applications/MAMP/fcgi-bin
PHP_FCGI_MAX_REQUESTS: 200
__CF_USER_TEXT_ENCODING: 0x1F5:0x0:0x2
ORIG_SCRIPT_NAME: /fcgi-bin/php7.0.13.fcgi
ORIG_PATH_TRANSLATED: /Users/Toby/Sites/catch/admin/core/settings/diagnostics/index.php
ORIG_PATH_INFO: /admin/core/settings/diagnostics/index.php
ORIG_SCRIPT_FILENAME: /Applications/MAMP/fcgi-bin/php7.0.13.fcgi
SCRIPT_NAME: /admin/core/settings/diagnostics/index.php
REQUEST_URI: /admin/core/settings/diagnostics/?extended
QUERY_STRING: extended
REQUEST_METHOD: GET
SERVER_PROTOCOL: HTTP/1.1
GATEWAY_INTERFACE: CGI/1.1
REDIRECT_URL: /admin/core/settings/diagnostics/index.php
REDIRECT_QUERY_STRING: extended
REMOTE_PORT: 62391
SCRIPT_FILENAME: /Users/Toby/Sites/catch/admin/core/settings/diagnostics/index.php
SERVER_ADMIN: you@example.com
DOCUMENT_ROOT: /Users/Toby/Sites/catch
REMOTE_ADDR: ::1
SERVER_PORT: 8888
SERVER_ADDR: ::1
SERVER_NAME: loc.catch
SERVER_SOFTWARE: Apache
PATH: /usr/bin:/bin:/usr/sbin:/sbin
HTTP_COOKIE: cmssb=1; PHPSESSID=a5ad4b785bd9dbfecdf2e81c93429686; cmsa=1
HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.8
HTTP_ACCEPT_ENCODING: gzip, deflate, sdch
HTTP_REFERER: https://loc.catch:8888/admin/core/settings/diagnostics/add-ons/
HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36
HTTP_UPGRADE_INSECURE_REQUESTS: 1
HTTP_CONNECTION: keep-alive
HTTP_HOST: loc.catch:8888
REDIRECT_STATUS: 200
REDIRECT_HANDLER: php-fastcgi
FCGI_ROLE: RESPONDER
PHP_SELF: /admin/core/settings/diagnostics/index.php
REQUEST_TIME_FLOAT: 1495101752.46
REQUEST_TIME: 1495101752
argc: 1
Toby Martin

Toby Martin 1 points

  • 4 years ago

The slug tag isn't in the master template, but I had already tried adding it in and using urlencode="true"

You may need to add the urlencode attribute to the tag that slug is referencing... I am away from office so unable to test.

Yeah adding it to postTitle doesn't work either

These changes need to be made in the post.html template which is used when the post is originally saved. If this isn't made in that template it won't work. Also, make sure your re-saving the post as template changes will not work until re-saved.

Yep changes are being made to post.html, and yes the post is being resaved on edits to the template.

Lastly, is the slug editable? As the slug will only be saved at time of original save, so I would be creating a new post with each attempt to change the template and not editing an existing post.

Yeah, even including this:

<perch:blog id="postSlug" editable="true" urlencode="true" />

Doesn't resolve the issue

Drew McLellan

Drew McLellan 2638 points
Perch Support

You're missing type="slug"

I've added that now, however the '=' remains. Then if I manually remove it and save the template, it reverts back.

But I would prefer not to give the user control of the slugs anyway, so would there be a way auto encode the slug?

That equals sign is a valid character in a URL. Therefore it doesn't require encoding

So maybe it's the routing that's the issue?

At the mo I'm just using news/[slug:s]

Drew McLellan

Drew McLellan 2638 points
Perch Support

The slug token won't match the = sign, no.