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

support for html encoded strings #20

Open
objecttothis opened this issue Mar 25, 2024 · 8 comments · May be fixed by #21
Open

support for html encoded strings #20

objecttothis opened this issue Mar 25, 2024 · 8 comments · May be fixed by #21
Assignees
Labels

Comments

@objecttothis
Copy link

objecttothis commented Mar 25, 2024

Currently if I pass & through, namecase changes it to &Amp; which breaks decoding. Please add an ignore for html encoded entities.
<, >, &amp, ' and "

@objecttothis
Copy link
Author

Here is what I'm having to do currently to get around the problem:

		$adjusted_name = str_name_case($input);

		// Use preg_replace_callback to match HTML entities and convert them to lowercase.
		$adjusted_name = preg_replace_callback('/&[a-zA-Z0-9#]+;/', function($matches) {
			return strtolower($matches[0]);
		}, $adjusted_name);

		return $adjusted_name;

@tamtamchik tamtamchik added the bug label Jul 23, 2024
@tamtamchik tamtamchik self-assigned this Jul 23, 2024
tamtamchik added a commit that referenced this issue Jul 23, 2024
@tamtamchik tamtamchik linked a pull request Jul 23, 2024 that will close this issue
@tamtamchik
Copy link
Owner

I'm sorry for the late fix! @objecttothis but is it possible to ask you to verify the fixed version:

composer require tamtamchik/namecase:3.1.0-beta.0

@tamtamchik tamtamchik linked a pull request Jul 23, 2024 that will close this issue
@objecttothis
Copy link
Author

Thank you for this fix. I work on the project which uses this library on Mondays and Tuesdays so I'll make a note to test it on Monday. We are at end of day Tuesday here.

@objecttothis
Copy link
Author

I'm sorry for the late fix! @objecttothis but is it possible to ask you to verify the fixed version:

composer require tamtamchik/namecase:3.1.0-beta.0

Just tested 3.1.0-beta.0 and the following
image

gets replaced with
image

Which is what I would expect, but this
image

gets replaced with
image

I didn't get this behavior every time, though it was unclear to me exactly which circumstances it was giving the correct output

@objecttothis
Copy link
Author

objecttothis commented Jul 29, 2024

I think my example isn't really clear.

When I submit
image

the first time I got
image

and that is what I expect to get back. However when I resubmit
image

I get
image

which is not expected. The difference between the two is that the first requires capitalization of joe. I was able to repeat the result, so it's something to do with the way it's handling Joe & differently than joe &

@tamtamchik
Copy link
Owner

Thank you for the feedback, @objecttothis; that is why I didn't publish it as a new release. I'll debug and fix the issue ASAP.

@tamtamchik
Copy link
Owner

tamtamchik commented Aug 6, 2024

@objecttothis, try this one; sorry for being late, I was trying different approaches, but the one you use looks like the most reliable.

composer require tamtamchik/namecase:3.1.0-beta.1

@objecttothis
Copy link
Author

Sounds good. I'm out of the office until the 16th but I'll test it then if it's still needed.

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

Successfully merging a pull request may close this issue.

2 participants