# Uppercase letter detection appears to be ignoring accented letters

**URL:** <https://meta.discourse.org/t/uppercase-letter-detection-appears-to-be-ignoring-accented-letters/26763>\
**Category:** Bug\
**Created:** [2015年三月25日 11:35 UTC](https://meta.discourse.org/t/uppercase-letter-detection-appears-to-be-ignoring-accented-letters/26763 "2015-03-25T11:35:15Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![RaceProUK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/raceprouk/32/115844_2.png) [@RaceProUK](https://meta.discourse.org/u/RaceProUK)\
**Post date:** [2015年三月25日 11:35 UTC](https://meta.discourse.org/t/uppercase-letter-detection-appears-to-be-ignoring-accented-letters/26763/1 "2015-03-25T11:35:15Z")

</div>

> **[What the Daily WTF?](https://what.thedailywtf.com/login)**

Just one is enough to get past the ‘is this content’ filter, as the post below shows.

Not a biggie, just seems a little inconsistent, s’all.

---

<div class="post-metadata">

**Author:** ![RaceProUK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/raceprouk/32/115844_2.png) [@RaceProUK](https://meta.discourse.org/u/RaceProUK)\
**Post date:** [2015年三月25日 11:35 UTC](https://meta.discourse.org/t/uppercase-letter-detection-appears-to-be-ignoring-accented-letters/26763/2 "2015-03-25T11:35:43Z")

</div>

ÁN EXAMPLE REPRODUCTION HERE TOO

---

<div class="post-metadata">

**Author:** ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)\
**Post date:** [2015年三月25日 15:02 UTC](https://meta.discourse.org/t/uppercase-letter-detection-appears-to-be-ignoring-accented-letters/26763/3 "2015-03-25T15:02:41Z")

</div>

The Uppercase detection is one of those features where we just handle the simplest and most basic version of the issue and leave it up to moderators to enforce it otherwise.

Why? Well as you noticed there are hundreds of thousands of unicode endpoints that would break it. It is just not practical to get them all when it’s easier to tell a user, “hey, stop doing that!”

---

<div class="post-metadata">

**Author:** ![RaceProUK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/raceprouk/32/115844_2.png) [@RaceProUK](https://meta.discourse.org/u/RaceProUK)\
**Post date:** [2015年三月25日 15:15 UTC](https://meta.discourse.org/t/uppercase-letter-detection-appears-to-be-ignoring-accented-letters/26763/4 "2015-03-25T15:15:11Z")

</div>

True I guess, but IIRC, the .NET Framework has an API for asking whether a letter is upper or lower case; does whatever Discourse runs on (Ruby On Rails?) not have an equivalent? Or would that slow things down too much?

---

<div class="post-metadata">

**Author:** ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)\
**Post date:** [2015年三月25日 15:28 UTC](https://meta.discourse.org/t/uppercase-letter-detection-appears-to-be-ignoring-accented-letters/26763/5 "2015-03-25T15:28:54Z")

</div>

Ruby provides an API to do this, and we use it, however it is only effective for ASCII. So when non-ASCII characters are present we skip the check. We were bitten by this previously with foreign languages.

---

<div class="post-metadata">

**Author:** ![RaceProUK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/raceprouk/32/115844_2.png) [@RaceProUK](https://meta.discourse.org/u/RaceProUK)\
**Post date:** [2015年三月25日 15:50 UTC](https://meta.discourse.org/t/uppercase-letter-detection-appears-to-be-ignoring-accented-letters/26763/6 "2015-03-25T15:50:33Z")

</div>

Well, that’s a bit… huh.

Eh, may as well close this now I guess.

---

<div class="post-metadata">

**Author:** ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)\
**Post date:** [2015年三月25日 15:52 UTC](https://meta.discourse.org/t/uppercase-letter-detection-appears-to-be-ignoring-accented-letters/26763/7 "2015-03-25T15:52:10Z")

</div>



---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2015年三月25日 22:59 UTC](https://meta.discourse.org/t/uppercase-letter-detection-appears-to-be-ignoring-accented-letters/26763/8 "2015-03-25T22:59:54Z")

</div>

You can actually do this in Ruby it just means you need to be a tad more fancy

> <https://stackoverflow.com/questions/8529595/how-can-i-check-a-word-is-already-all-uppercase/11415950#11415950>

```plaintext
utf_pattern = Regexp.new("\\p{Lower}".force_encoding("UTF-8"))

a = "Go234"
a.match(utf_pattern) # => #<MatchData "o">

b = "GO234"
b.match(utf_pattern) # => nil

b = "ÜÖ234"
b.match(utf_pattern) # => nil

b = "Über234"
b.match(utf_pattern) # => #<MatchData "b">

```

---

<div class="post-metadata">

**Author:** ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)\
**Post date:** [2015年三月26日 06:47 UTC](https://meta.discourse.org/t/uppercase-letter-detection-appears-to-be-ignoring-accented-letters/26763/9 "2015-03-26T06:47:42Z")

</div>

Don’t forget Chinese/Japanese/Korean!

---

<div class="post-metadata">

**Author:** ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)\
**Post date:** [2015年三月26日 15:28 UTC](https://meta.discourse.org/t/uppercase-letter-detection-appears-to-be-ignoring-accented-letters/26763/10 "2015-03-26T15:28:46Z")

</div>

> [@sam](#):
>
> [http://stackoverflow.com/a/11415950/17174](http://stackoverflow.com/a/11415950/17174)

@neil is there a reason you didn’t use this approach? Looks like you were the one who did the ascii change.

---

<div class="post-metadata">

**Author:** ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)\
**Post date:** [2015年三月26日 15:59 UTC](https://meta.discourse.org/t/uppercase-letter-detection-appears-to-be-ignoring-accented-letters/26763/11 "2015-03-26T15:59:26Z")

</div>

I have no memory of this… It should use that approach. Also, can you do ALL CAPS in Chinese/Japanese/Korean??

---

<div class="post-metadata">

**Author:** ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)\
**Post date:** [2015年三月26日 18:06 UTC](https://meta.discourse.org/t/uppercase-letter-detection-appears-to-be-ignoring-accented-letters/26763/12 "2015-03-26T18:06:38Z")

</div>

I was saying to make sure that the behavior was correct, as it looks like that regex checks for “any lowercase”.

---

<div class="post-metadata">

**Author:** ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)\
**Post date:** [2015年三月26日 18:11 UTC](https://meta.discourse.org/t/uppercase-letter-detection-appears-to-be-ignoring-accented-letters/26763/13 "2015-03-26T18:11:19Z")

</div>

Huh I found this commit but maybe you took the approach from someone else?

[https://github.com/discourse/discourse/commit/876a570e3a2e227528d135a0cc67cccf442baaf1](https://github.com/discourse/discourse/commit/876a570e3a2e227528d135a0cc67cccf442baaf1)
