Comments (7)
Hey @Ross-Hunter!
watermark-text
accepts text in the Pango markup. Since it is an HTML-like language, it has the same special characters: <
, >
, and &
. All you need is to replace them with <
, >
, and &
respectively, or just use an HTML-escaping function from your language. Guess it is worth mentioning in the docs 🤔
from imgproxy.
do you use correct encoding?
show me your url please
from imgproxy.
Stepping in for ross here.
I think we should've filed this issue in imgproxy.rb
as that's what we're using here.
https://github.com/imgproxy/imgproxy.rb
I think our default assumption would've been that the gem would take care to either make sure the watermark_text
was compliant by encoding it correctly, or raised an error directly, instead of returning an URL. In its current state, the issue was not obvious to figure out.
from imgproxy.
I don't think it's really possible. A user may want to use the Pango markup in the watermark_text
value, and if the gem escapes every watermark_text
value, it would ruin the markup.
The other way is to try to predict if the user tries to use markup or not. This will most probably lead to more confusion.
The third way is to try to parse the watermark_text
value and raise an error if the parsing fails. There we'll need something like Nokogiri or Ox just to check the value of a single option. Not a good idea IMHO. Also, we don't check values in imgproxy.rb
at all.
The fourth way is to add an argument to the watermark_text
option that disables the Pango markup. This is doable and, probably, is a good idea. But the markup will be enabled by default anyway since this is the current behavior, so the problem of "the issue was not obvious to figure out" won't be solved.
And last but not least: you can wrap the watermark_text
value with CGI::escapeHTML
right in your code, which will solve the problem completely 🙂
from imgproxy.
Hey @Ross-Hunter!
watermark-text
accepts text in the Pango markup. Since it is an HTML-like language, it has the same special characters:<
,>
, and&
. All you need is to replace them with<
,>
, and&
respectively, or just use an HTML-escaping function from your language. Guess it is worth mentioning in the docs 🤔
That was the issue. I did not see anything in the docs about special characters in watermark text.
I can tell that imgproxy.rb is properly base64 encoding the value, but if that value contains an ampersand, then imgproxy (go) returns a 500 -- however if I CGI.escapeHTML(watermark_text)
in ruby then it works as intended.
I suppose imgproxy.rb could handle that for folks, but I think you would still want to document the Pango markup behavior here for people not using imgproxy.rb.
Thanks for the help @DarthSim!
from imgproxy.
No problem! I'll definitely add a warning about this to the docs.
from imgproxy.
And of course, now I find it in the docs 🤦
https://docs.imgproxy.net/features/watermark#text-watermarks
I think I kept reading this and not quite registering that you must use pango markup to support special characters.
from imgproxy.
Related Issues (20)
- Option to report source image errors HOT 5
- Style transformation for SVG broken since 3.23 HOT 3
- Error: SVG detection does not work when it uses namespaces HOT 2
- Can't download source image: invalid JPEG format: missing SOF marker HOT 2
- ERROR png2vips: unable to read source source HOT 2
- Produces invalid SVG when namespaced attributes appear before namespace declaration HOT 1
- Support for external IDs when using S3 with assumed roles HOT 3
- Error: store of inconsistently typed value into Value HOT 1
- Requests to `imgproxy` randomly start timing out HOT 20
- [Feature Request] Apply an overlay over the whole image HOT 4
- Source image is unreachable HOT 2
- Autoquality HOT 2
- Font overlaps when converting SVG to JPG/PNG HOT 2
- [Question] I cannot manage to get watermarks to work HOT 4
- SVG rendering failed HOT 4
- Force transcoding/re-encoding HOT 2
- Disable source image download logs HOT 2
- Problem URL Encoded Parameters HOT 1
- All imgproxy instances become unhealthy at the same time 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 imgproxy.