No description
Find a file
Derek Crosson ae27d15be7
Prevent whitespace unicode characters from being used in article title and tag (#14909)
* test: whitespace unicode characters cannot be used as titles or tags

* feat: add localized error message

* refactor: use localized error message

* fix: whitespace unicode characters cannot be used as titles or tags

* chore: fix locale after merge

* refactor: fix indentation

* Fix spelling of prohibited in method names

Additionally, rubocop removed a redundant user_id validation since
Article belongs to user.

* Fix spelling

Missed one method call on the same line (fixed the first of two
instances needing changes)

* add failing test cases

The reorganization to remove let was due to a limit on nesting rspec
contexts (it inside context inside describe inside describe when
trying to use different titles in let blocks in contexts)

The first test was clarified (the "U+202D" string that looks like the
code for a unicode point is valid, but the character \u202d is
expected to be invalid

The remaining two tests are based on the feedback I'd given in the PR,
failing because we don't assert title is present after removing
unicode whitespace, and we don't actually set the title (gsub is
non-destructive, returning a value).

* Set title to sanitized title

contains_prohibitied_unicode_characters? was using == (which is not a
good match for strings to regexes), use =~ instead

Change invalid example characters in titles from \u202d (bidi override) to
\u200a (hair space)

Assert that the empty title is blank and can't be blank (even though
it contains no prohibitd characters after replacement)

* change the definition of prohibited characters

From the description, it looks like "unicode space characters" was the
desired rejection set. It was unclear what the existing regex was
matching on (I couldn't get the expected examples to match correctly).

Given the intent, I select "unicode space property, except the ascii
space character", which may _also_ be incorrect but passed the tests.

* Remove now-invalid expectation for presence of user id

Since this was redundant (belongs_to user), we no longer will validate
presence of user id, and we should not test for it.

* Only reject bidirectional text controls

The original issue pointed to the BIDI controls as problematic.

While they called out other "whitespace" characters, as we accept a
wider range of input languages, the need to handle non-printing
punctuation (for example a group separating space for some asian
languages).

It's possible a wider list of characters should be added - if that's
the case I suggest this regex and the sanitization be moved to a
standalone class, and each of the recommendations in
https://www.w3.org/TR/unicode-xml/#Charlist be checked for
applicability.

* Check for blank title after sanitizing disallowed characters

Since validate_title modifies the title, and doesn't set error
messages on the model itself, check for non-empty title _after_
potentially removing any disallowed characters.

* Remove invalid characters before validation

Remove the validate_title and contains_prohibited_characters methods,
and center all logic on the remove prohibitied unicode characters
method.

Remove unneeded and unused arguments (input string is always title,
replacement is always removal/empty string).

* handle case when validating null title

If the title's nil, we don't want to call match? since it will fail.

Title will sometimes be nil when validating.

Co-authored-by: Ben Halpern <bendhalpern@gmail.com>
Co-authored-by: Dan Uber <dan@forem.com>
2022-01-03 09:37:03 -05:00
.buildkite Removes this dupe container block since we are going to run this pipeline (#11506) 2020-11-19 15:05:49 -06:00
.gems Bugfix for #7663 and refactor of container setup (#7747) 2020-05-28 12:11:51 -05:00
.github Adding program language lens for Code Ownership (#15431) 2021-11-22 11:28:35 -05:00
.husky [15 min fix] Updated husky package and configuration/pre-commit hook (#14346) 2021-07-27 15:39:00 -04:00
.vscode Added the MDX extension for VS Code. (#12816) 2021-02-25 10:22:18 +01:00
.yarn/releases Update to latest yarn version (#10441) 2020-09-28 13:24:35 -04:00
app Prevent whitespace unicode characters from being used in article title and tag (#14909) 2022-01-03 09:37:03 -05:00
bin Monkey-patch instead of forking cypress-rails gem (#15797) 2021-12-16 11:36:45 -05:00
config Prevent whitespace unicode characters from being used in article title and tag (#14909) 2022-01-03 09:37:03 -05:00
cypress Add comment notification test to Cypress, including a11y improvements to notification page (#15842) 2021-12-21 15:42:13 +00:00
datadog Declare DD_VERSION in prerun.sh 2nd try (#13258) 2021-04-05 17:10:46 -04:00
db Remove Doorkeeper and webhook tables (#15854) 2021-12-29 10:09:14 +07:00
lib Monkey-patch instead of forking cypress-rails gem (#15797) 2021-12-16 11:36:45 -05:00
log Initial commit 2018-02-28 16:11:08 -05:00
public Make podcast-playback to be controllable via keyboard (#14139) 2021-08-20 12:45:53 +02:00
scripts Don't write a \n at the end of the release version (#15659) 2021-12-03 13:08:27 -05:00
spec Prevent whitespace unicode characters from being used in article title and tag (#14909) 2022-01-03 09:37:03 -05:00
vendor Bump rubocop-performance from 1.12.0 to 1.13.0 (#15885) 2021-12-29 21:45:40 +07:00
.codeclimate.yml Upgrade to Ruby 3.0.2 (#12103) 2021-08-25 14:26:33 -04:00
.dockerignore Remove docs from repo ✂✂✂ (#14579) 2021-08-23 17:23:42 -04:00
.editorconfig Export articles/posts (#576) 2018-11-21 11:13:36 -05:00
.env_sample ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
.erb-lint.yml Upgrade Rails to 6.1.3.1 (#11333) 2021-04-05 10:39:48 -04:00
.eslintignore Remove non application files from frontend code coverage (#11752) 2020-12-04 20:00:20 -05:00
.eslintrc.js Disabled 'no default exports' rule for Storybook files and Stimulus controllers (#13032) 2021-03-17 21:29:39 -04:00
.gitattributes Enable union merges for translations (#15061) 2021-10-14 10:51:09 +07:00
.gitignore Add .pryrc to gitignore (#14844) 2021-09-28 18:03:02 +02:00
.gitpod.dockerfile Made GitHub CLI install permanent in Gitpod (#14787) 2021-09-21 15:27:39 -04:00
.gitpod.yml Add DISABLE_SPRING environment variable to gitpod forem server task (#15807) 2021-12-16 15:24:22 -06:00
.lintstagedrc.js Create .lintstagedrc.js (#15209) 2021-10-27 12:40:59 -04:00
.nvmrc Update to use Node 14.x (#13136) 2021-03-29 11:27:20 -04:00
.postcssrc.yml Initial commit 2018-02-28 16:11:08 -05:00
.prettierignore Use yarn 1.21.1 (#5786) 2020-02-05 17:04:06 -05:00
.prettierrc.json Extracting prettier config (#10847) 2020-10-14 22:28:31 -04:00
.rspec [deploy] Spec Speedup: Use Knapsack to Run Parallel Builds (#8390) 2020-06-11 10:27:11 -05:00
.rubocop.yml Rubocop fixes (#14868) 2021-09-30 13:22:09 -04:00
.rubocop_todo.yml ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
.ruby-version Upgrade to Ruby 3.0.2 (#12103) 2021-08-25 14:26:33 -04:00
.simplecov Remove resource_admin dashboards (Administrate) (#11792) 2020-12-08 12:38:13 -06:00
.slugignore Remove docs from repo ✂✂✂ (#14579) 2021-08-23 17:23:42 -04:00
.travis.yml Add assets precompile check to the miscellaneous tasks node (#15280) 2021-11-03 18:09:44 -05:00
.yardopts Adds Ruby source code documentation to docs.dev.to (#2656) 2019-05-02 13:50:58 -04:00
.yarnclean Remove assets folder from .yarnclean (#13869) 2021-05-27 10:39:59 -04:00
.yarnrc Update to latest yarn version (#10441) 2020-09-28 13:24:35 -04:00
babel.config.js Added the babel-inline-react-svg plugin (#15461) 2021-11-23 12:24:50 -05:00
CHANGELOG.md Add support for versioned releases (#13750) 2021-07-28 10:10:33 -04:00
CODE_OF_CONDUCT.md Replace ban/banned with suspend/suspended in user facing text (#5816) [deploy] 2020-02-10 10:12:53 -05:00
config.ru Upgrade Rails to 6.1.3.1 (#11333) 2021-04-05 10:39:48 -04:00
container-compose.yml Remove Elasticsearch ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ (#13606) 2021-05-03 11:09:45 -04:00
Containerfile Specify a single base image for builder and production (#15678) 2021-12-06 11:27:12 -06:00
CONTRIBUTING.md Fix broken links (#14588) 2021-08-24 16:59:56 -04:00
customJsDomEnvironment.js Bump jsdom from 16.7.0 to 18.0.0 (#15047) 2021-10-12 14:32:30 -06:00
cypress.dev.json Cleaning Test Runs for End to End (E2E) Tests (#12143) 2021-01-29 13:34:01 +01:00
cypress.json add retries for cypress ci tests (#14241) 2021-07-15 12:34:30 +01:00
docker-compose.yml Update docker-compose.yml file to permit login (#13792) 2021-05-24 20:03:36 -05:00
Dockerfile Bugfix for #7663 and refactor of container setup (#7747) 2020-05-28 12:11:51 -05:00
empty-module.js Initial commit 2018-02-28 16:11:08 -05:00
Gemfile Bump rubocop-performance from 1.12.0 to 1.13.0 (#15885) 2021-12-29 21:45:40 +07:00
Gemfile.lock Bump rubocop-performance from 1.12.0 to 1.13.0 (#15885) 2021-12-29 21:45:40 +07:00
gitpod-init.sh Made GitHub CLI install permanent in Gitpod (#14787) 2021-09-21 15:27:39 -04:00
Guardfile Upgrade rubocop* packages to the latest version and fix violations (#11972) 2020-12-21 18:29:43 +01:00
jest.config.js Crayons: Buttons vs CTAs (#15311) 2021-11-30 20:40:32 +01:00
jsconfig.json Added the babel-inline-react-svg plugin (#15461) 2021-11-23 12:24:50 -05:00
LICENSE.md Ran all markdown files through prettier to fix a handful. (#4599) 2019-10-28 08:20:53 -04:00
package.json Bump eslint-plugin-react from 7.27.1 to 7.28.0 (#15901) 2021-12-30 12:02:18 -06:00
postcss.config.js Suppress Postcss warnings & Re-enable Benhalpern deploy (#11521) 2020-11-20 11:27:49 -05:00
Procfile remove rake jobs:work references from code (#6082) [deploy] 2020-02-14 15:18:08 -05:00
Procfile.dev Adapt dev env to run on a remote box (#8232) 2020-06-18 13:01:49 +02:00
Procfile.dev-hot Initial commit 2018-02-28 16:11:08 -05:00
Rakefile Remove fix-db-schema-conflicts gem (#12432) 2021-01-26 10:52:38 -05:00
README.md Add me (Dwight) to readme :) (#15816) 2021-12-17 14:50:45 -05:00
release-tasks.sh Remove Elasticsearch ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ (#13606) 2021-05-03 11:09:45 -04:00
SECURITY.md [deploy] 🚀 Feature: Chat channel membership manager component (#8945) 2020-07-20 08:08:31 -04:00
svgo.config.js svgo: update configuration for 2.4 syntax (#14524) 2021-08-17 18:54:10 +02:00
testSetup.js workaround getComputedStyle issues in all jest tests (#14737) 2021-09-21 10:52:54 +01:00
yarn.lock Bump eslint-plugin-react from 7.27.1 to 7.28.0 (#15901) 2021-12-30 12:02:18 -06:00


Forem 🌱

For Empowering Community

Travis Status for forem/forem GitHub commit activity GitHub issues ready for dev GitPod badge

Welcome to the Forem codebase, the platform that powers dev.to. We are so excited to have you. With your help, we can build out Forems usability, scalability, and stability to better serve our communities.

What is Forem?

Forem is open source software for building communities. Communities for your peers, customers, fanbases, families, friends, and any other time and space where people need to come together to be part of a collective. See our announcement post for a high-level overview of what Forem is.

dev.to (or just DEV) is hosted by Forem. It is a community of software developers who write articles, take part in discussions, and build their professional profiles. We value supportive and constructive dialogue in the pursuit of great code and career growth for all members. The ecosystem spans from beginner to advanced developers, and all are welcome to find their place within our community. ❤️

Table of Contents

Community

For a place to have open discussions on features, voice your ideas, or get help with general questions please visit our community at forem.dev.

Contributing

We encourage you to contribute to Forem! Please check out the Contributing to Forem guide for guidelines about how to proceed.

Getting Started

This section provides a high-level quick start guide. If you're looking for a more thorough installation guide (for example with macOS, you'll want to refer to our complete Developer Documentation.

We run on a Rails backend, and we are currently transitioning to a Preact-first frontend.

A more complete overview of our stack is available in our docs.

Prerequisites

Local

Containers

Linux

OS X

Installation Documentation

Please see our installation guides, such as the one for macOS.

Developer Documentation

Check out our dedicated docs page for more technical documentation.

Core team

Vulnerability disclosure

Forem is the open source software which powers DEV.

We welcome security research on DEV under the terms of our vulnerability disclosure policy.

Acknowledgments

Thank you to the Twemoji project for the usage of their emojis.

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Please see the LICENSE file in our repository for the full text.

Like many open source projects, we require that contributors provide us with a Contributor License Agreement (CLA). By submitting code to the Forem project, you are granting us a right to use that code under the terms of the CLA.

Our version of the CLA was adapted from the Microsoft Contributor License Agreement, which they generously made available to the public domain under Creative Commons CC0 1.0 Universal.

Any questions, please refer to our license FAQ doc or email yo@dev.to.


Sloan, the sloth mascot
Happy Coding ❤️

⬆ Back to Top