Giter Club home page Giter Club logo

Comments (6)

mabar avatar mabar commented on September 22, 2024 2

Input of link must be string and casting would only hide errors. Even casting just Html would hide errors -> Html instance usually does not make sense to be an input for link.
Capture is mostly for html context so it's also correct to return Html. Maybe it could be made context-aware and always output string for non-html input.
Otherwise I would use explicit casting to string in user code.

from application.

dg avatar dg commented on September 22, 2024 1

Yeah. But you'd have to do a lot of checks in a lot of places. It would probably be more practical to switch to strictTypes = true in general, or remove Html::__toString(), or modify __toString() to return ASCII.

from application.

lulco avatar lulco commented on September 22, 2024

Basically I agree, I mentioned it in original @spaze’s issue efabrica-team/phpstan-latte#398

from application.

spaze avatar spaze commented on September 22, 2024

A similar problem was reported (and fixed) in nette/latte#326, passing Html to img src caused troubles.

Code taken from that issue that didn't work before but not works:

{capture $test}https://nette.org{/capture}
<img src="{$test}">

It's similar enough that I'd say it would make sense for the code used in this issue to also work. What do you think?

from application.

dg avatar dg commented on September 22, 2024

The difference is in the n:href and src. The former contains PHP code and unicode strings, the latter HTML.

{capture $link}foo&#43;bar{/capture}
<img src="{$link}">   ->   <img src="foo&#43;bar">     OK
<a n:href="$link">    ->   <?php $link = 'foo&#43;bar';  // BAD!!!
                                 $link = 'foo+bar';      // THIS IS OK 

from application.

spaze avatar spaze commented on September 22, 2024

I see, thanks. So just to make sure I understand it correctly, \Nette\Bridges\ApplicationLatte\Nodes\LinkNode should ideally check whether $destination is a string and not an Html object to make sure it works as intended even with $strictTypes = false, is that correct?

from application.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.