-
Notifications
You must be signed in to change notification settings - Fork 27.5k
fix(ngSanitize) - fixed the problem with relative links #4736
Conversation
fixed the problem that relative links was removed by the htmlParser function Closes #3748
is there a reason why we can't use $sce.getTrustedResourceUrl() for href/src? --- Having a single whitelist/blacklist seems like a sensible approach to this |
That's awesome, thank you. I started playing around with this and made a fix in the regex in linky.js. Doesn't |
@caitp - that sounds like a good idea. I don't think the sanitize parser has had much attention since before |
@janbaer - have you signed the CLA? |
Yes I did it! |
Hi, However, there is another duplication which we should remove and which will also fix this bug: The idea would be make @janbaer Would you like to update your pull request (including the tests) accordingly? For the unit tests, you can have a look at the unit tests for the link sanitizing in |
* angular/master: (140 commits) fix(ngAnimate): use a fallback CSS property that doesn't break existing styles refactor($sce): Use $sniffer instead of $document for feature detection. fix(ngClass): ensure that ngClass only adds/removes the changed classes fix($animate): ensure the DOM operation isn't run twice fix(ngInclude): allow ngInclude to load scripts when jQuery is included docs($log): the documented default log behavior was incorrect docs(ngAnimate): fixed two small typos docs(booleanAtts): explain the motivation for boolean attributes docs(tutorial/step-2): correct the link to jasmine docs docs(ngRepeat): fix typo docs(ngPluralize): Fix missing space before parentheses docs(guide/directive): use `hideDialog` handler in example docs(guide/ie): fix typo docs(guide/providers): remove extra closing parenthesis in example docs(guide/migration): fix typo docs(guide/compiler): fix typo in isolate scope def docs(api): example for $provide.value() uses $provide.value() docs(ngRoute): make it easier to find the example docs(tutorial): minimum node.js version is 0.10 (Windows too) docs(guide/migration): fix typo ...
@tbosch Ok, I can try it. But "and use almost the same code snippet from $compile" sounds like code duplication. Maybe we should think about a common UrlValidator that has the regex in it self... |
Actually, you don't have to repeat the tests: |
@tbosch I'm sorry I've tried but I think this change is more complicated then I've (and maybe you) thought. The first is, that both regexp are totally different. URI_REGEXP = /^((ftp|https?)://|mailto:|tel:|#|/)/i I don't mean the different naming conventions. I've just tried to replace the regexp in sanitize.js and all tests for isUri was failed. Ok I can try to change the regex so that it will run. But than I had a problem with the tests in compileSpec.js. The other problem is that the regexp will not be exported from the $compile module. I don't think that it's a good a idea to have a dependency to another module to use just a common regexp. I think it would be better to accept the small change that I've made so that we can use it in the next version (1.2.3) and then thinking about how the $sanitize module can use more functionality from $compile as a regexp. But it's not my decision, maybe I'm wrong... |
Hi @janbaer, To get this into our next release on Wednesday, I created an own PR: #5137 Thanks for your help and reporting this! |
Hi @tbosch, thanks for your PR! When it's merged and released, I can reuse the official release of #angular.js in my project! 👍 |
Woot! Thank you! 👍 |
Closing this as the other PR is already in master via commit 3335234, |
fixed the problem that relative links was removed by the htmlParser function
Closes #3748