Comments (11)
It shouldn't touch any attribute. Do you have an example where it is?
from autolinker.js.
I was mistaken about the cause. It works fine with the src attribute alone, but my tag contains more stuff.
<img src='http://terryshoemaker.files.wordpress.com/2013/03/placeholder1.jpg' style=' height: 22px; background-color: rgb(0, 188, 204); border-radius: 7px; padding: 2px; margin: 0px 2px;'>
turns into
<img src="<a href="http://terryshoemaker.files.wordpress.com/2013/03/placeholder1.jpg" target="_blank">terryshoemaker.files.wordpress.com/2013/03/placeholder1.jpg</a>" style=" height: 22px; background-color: rgb(0, 188, 204); border-radius: 7px; padding: 2px; margin: 0px 2px;">
from autolinker.js.
Anything happen differently if you remove the whitespace before height: 22px
?
from autolinker.js.
(still a bug either way btw, just curious. Might be able to take a look tomorrow)
from autolinker.js.
Yeah, removing the space does fix it.
I'm using AngularJS, so I've got a bit in the html that has nested and escaped quotes, so that space sneaks in there somehow.
from autolinker.js.
Hey @alphatwit. So sorry for the late reply. I finally got a chance to look at this.
However, I can't seem to reproduce the issue. Are you using the latest version? If so, can you post more of your HTML? Perhaps another tag that surrounds your image is causing the problem. Also, can you post the options that you're using?
Thanks,
Greg
from autolinker.js.
Same thing was happening to me with this piece of HTML:
Just a flower image <img src="https://farm9.staticflickr.com/8378/8578790632_83c6471f3f_b.jpg" />
The problem is the htmlRegex wasn't recognizing the IMG tag with attributes. I changed that regular expression to one way simpler:
htmlRegex : /<(\/)?([0-9a-zA-Z:]+)(?:\s+[^>]+)*\s*>/g,
In yours you are trying to parse the attributes but never use them so, sorry for asking but, what's the point? @alphatwit give this regular expression a try please.
from autolinker.js.
I've changed my code since then, but it was something like this:
<form class="approval-form" name="thumbsUp" ng-submit="postApproval()"> <button type="submit"> <img class="thumbs-up" ng-click="comment.body='<img src=\'http://example.com/api-public/images/wg/w/Rating_and_Approval/icon-thumbs-up.png\' style=\'height: 22px; background-color: rgb(0, 188, 204); border-radius: 7px; padding: 2px; margin: 0px 2px;\'>'+comment.body;" ng-src="http://example.com/api-public/images/wg/w/Rating_and_Approval/icon-thumbs-up.png"> </button> </form>
from autolinker.js.
Ah, got it, the issue in your HTML is with the IMG tag quoted inside the comment.body. In that case I'd recommend move the click implementation to the controller instead of the template and run Autolinker.link on the comment element after that.
from autolinker.js.
It's just prepending the html as a string to the comment.body. The mess of quotes and escaped quotes is because I'm doing it all in the template. That gets sent to the server. This is the code that is supposed to display the stuff inside comment.body
'<p ng-class="{\'message-snippet\':true}">' + '<span ng-bind-html = "message.data.body | autoLinker | unsafe"></span>'+ '</p >' +
At some point that space makes it into the style attribute and that causes the thing to break.
from autolinker.js.
@juliomenendez, in your example, the img tag's src
attribute wasn't actually the problem. The htmlRegex in Autolinker wasn't handling self-closing tags.. Whoops! I'm surprised nobody noticed this until now. Fixed in 0.11.1
The reason for the more-complex htmlRegex in the code is to try to handle as many cases as possible. The simpler regex wouldn't work correctly if an attribute had a >
character within it :)
@alphatwit, are you still having a problem? I wouldn't recommend having tags within tags, although copying/pasting your example seems to still autolink correctly. If you're still having a problem, can you copy/paste the html that is produced by your template before autolinking?
from autolinker.js.
Related Issues (20)
- 3 seconds to parse link in safari HOT 7
- Request: Add taiwanese style phone number format
- URL with multiple email addresses in query string is not linked correctly
- Autolinker vulnerable to RTLO URL spoofing attacks HOT 26
- Bug: getUrl method not working correctly for links in markdown formats HOT 1
- doc/release v3.16.0 changelog missing HOT 1
- urls.wwwMatches usecase HOT 4
- Links with `¬` in query string are broken
- encoded email address is split
- Wrong result when parsing CJK(中文/日文/韩文) char followed by colon HOT 1
- Failed to parse source map HOT 2
- Add support for YouTube hashtags HOT 1
- Add support for YouTube mentions HOT 1
- Url with protocol prefixed with emoji being incorrectly parsed HOT 1
- Help to create Markdown Link Matcher
- Enable `inlineSources`
- URL as value in key-value pair parsed only partially (and incorrectly)
- [Tiktok mentions] - parsing does not match tiktok mention behaviour HOT 2
- Detection If a Persian word is attached before the link
- Help fix
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 autolinker.js.