Comments (6)
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.
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.
Basically I agree, I mentioned it in original @spaze’s issue efabrica-team/phpstan-latte#398
from application.
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.
The difference is in the n:href
and src
. The former contains PHP code and unicode strings, the latter HTML.
{capture $link}foo+bar{/capture}
<img src="{$link}"> -> <img src="foo+bar"> OK
<a n:href="$link"> -> <?php $link = 'foo+bar'; // BAD!!!
$link = 'foo+bar'; // THIS IS OK
from application.
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)
- Nette Request doesn't have FETCH API fix HOT 2
- `UnexpectedValueException` with `$throw` = false on presenter->getComponent
- Route constructUrl incorrectly builds a URL on a non-standard port HOT 1
- BC break in patch version: Component::link() signature
- Routing panel throws exception from UrlScript HOT 1
- Invalid type of parameter in url throws InvalidLinkException HOT 1
- Session-less store/restoreRequest HOT 2
- Persistent attribute used for persistent controls does not allow params with control names
- Combination of nette/application 3.1.7 and nette/utils 3.2.7 triggers a deprecation error in Tracy HOT 7
- Ugly look of Tracy routing bar
- Missing barebone JS library for AJAX/snippet HOT 16
- Flash sessions - deprecated getter
- Nette Application 3.1.12 breaks compatibility with Latte 2 HOT 1
- ComponentReflection::convertType() empty string problem
- Custom form macros are overridden by default ones
- Link with a class constant as an argument cannot be parsed
- Link to the current page doesn't contain all URL parameters HOT 7
- Tracy red exception page not displayed on BadRequestException HOT 2
- No services of type XyzPresenter found. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from application.