Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

While loop that hangs on "strange" characters #254

Open
enkelmedia opened this issue Feb 20, 2019 · 0 comments
Open

While loop that hangs on "strange" characters #254

enkelmedia opened this issue Feb 20, 2019 · 0 comments

Comments

@enkelmedia
Copy link

Hi!

Just wanted to share a strange issue that we had.

Some visitor on our forum posted this symbol as content ➗ , which actually made the code end up in an endless loop on this row:

while (tmpStr.IndexOf(" ") != -1)

It seems like the replace-method don't replace the " " when this character is there, in our case the CPU usage went to 99% after hitting a topic in the forum with this sign. Removing the sign from the post content i the database OR removing the while loop above solved the issue.

I also don't understand why the while loop is there? The Replace-method in C# will replace all occurrences of the search string in one call (https://docs.microsoft.com/en-us/dotnet/api/system.string.replace?view=netframework-4.7.2).

So to avoid these ever lasting loops I would remove the while-loop from the methods that is counting words.

All the best!

// Markus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant