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

fix substr outside of string in Mojo::Asset::Memory #964

Closed
wants to merge 1 commit into from
Closed

fix substr outside of string in Mojo::Asset::Memory #964

wants to merge 1 commit into from

Conversation

leejo
Copy link
Contributor

@leejo leejo commented May 26, 2016

We updated to v6.62 (from v6.42) this morning and are seeing some odd behaviour, after a restart we sometimes get pages rendered as the raw HTML as if the headers are being sent through twice. We're still investigating this.

The one thing i do notice is substr outside of string at lib/perl5/site_perl/5.16.3/Mojo/Asset/Memory.pm line 41 warnings since the update. I've included a PR here to fix this issue. The important point is that a substr outside of a string will return undef and if that is being fed into length then unexpected things might be happening, observe:

> perl -E 'say length(substr("foo",4))'

> perl -E 'say length(substr("foo",3))'
0

given a substr outside of a string will return undef, if this is
being fed into a length call we are going to get undef rather than
0, which may cause weirdness upstream

add a test to check calling ->get_chunk outside of the string does
return '' rather than undef
@kraih
Copy link
Member

kraih commented Jun 3, 2016

Thanks for your effort, but i'm afraid this pull request did not pass the vote.

@kraih kraih closed this Jun 3, 2016
@mattp-
Copy link

mattp- commented Apr 17, 2017

seeing this as well, unsure what the cause is. if there is a reason this was rejected, can you help explain how to stop this warning from occurring?

@kraih
Copy link
Member

kraih commented Apr 17, 2017

@mattp- This was submitted as a new feature, instead of a bug fix. Which means it needs a certain number of votes to be accepted, and that it did not reach.

@mattp-
Copy link

mattp- commented Apr 17, 2017

ah ok. I actually just realized what was causing this for any future people who stumble upon this kind of issue:
I was rendering twice by calling $c->reply->not_found, but not actually returning in the controller method itself, so a second render was occurring with null/undef being returned. thanks for the quick response.

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

Successfully merging this pull request may close these issues.

None yet

3 participants