[wp-meta] [Making WordPress.org] #5083: Plugin Directory: Improve Trademark checks
Making WordPress.org
noreply at wordpress.org
Thu Mar 19 00:23:37 UTC 2020
#5083: Plugin Directory: Improve Trademark checks
------------------------------+---------------------
Reporter: Ipstenu | Owner: (none)
Type: defect | Status: new
Priority: normal | Milestone:
Component: Plugin Directory | Resolution:
Keywords: has-patch |
------------------------------+---------------------
Changes (by coffee2code):
* keywords: => has-patch
Comment:
Regarding the check performed in `has_trademarked_slug()`, wouldn't it be
better to differentiate the two types of intended checking being implied
Terms that end in "-" denote terms that cannot be the start of a plugin
name. For instance, we have "bing-". However, the check is being performed
via `strpos()`, so that actually checks anywhere in the string. A
hypothetical slug "tabbing-controls" would fail this check.
For trademark terms not ending in "-", the `strpos()` check is valid,
assuming we don't add too generic of a term. (e.g. "woo-" is valid to
denote something starting with "woo", but "woo" as a term is bad since it
would match too many valid words). Using `preg_match()` and checking for
word boundaries would be more precise, but perhaps overkill, as long as
trademarks don't balloon.
Anyhow, proposed change for the relevant section of
`has_trademarked_slug()`:
{{{
foreach ( $trademarked_slugs as $trademark ) {
// Trademarks ending in "-" indicate slug cannot begin with
that term.
if ( '-' === $trademark[-1] ) {
if ( 0 === strpos( $this->plugin_slug, $trademark ) ) {
$has_trademarked_slug = $trademark;
break;
}
}
// Otherwise, the term cannot appear anywhere in slug.
elseif ( false !== strpos( $this->plugin_slug, $trademark ) )
{
$has_trademarked_slug = $trademark;
break;
}
}
}}}
Assuming that change looks good and I haven't misunderstood things, I
think the patch + my changes look good.
--
Ticket URL: <https://meta.trac.wordpress.org/ticket/5083#comment:5>
Making WordPress.org <https://meta.trac.wordpress.org/>
Making WordPress.org
More information about the wp-meta
mailing list