Giter Club home page Giter Club logo

favicon's People

Contributors

leonbreedt avatar leonbreedt-sap avatar tschmitz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

favicon's Issues

Possible race condition when downloading associated files

Second nested executeURLOperations() may set .suspended = true on NSOperationQueue before first nested executeURLOperations() has finished adding dependent operations.

Make it atomic by collection operations and adding to one batch, and then predictably executing batch after processing /html/head.

Deployment target is iOS 11.2?

Is iOS 11.2 required? If not, can you change to a lower version cause I'm using Carthage to use your library. Thanks.

"FavIcon was compiled with optimization - stepping may behave oddly; variables may not be available."

Getting this weird crash...when I try to grab the icon for this url:

"http://www.npr.org/sections/thesalt/2015/12/03/457124796/death-by-coconut-a-story-of-food-obsession-gone-too-far"

Not sure why but I suspect it has something to do with the "/457124796/" url component...possibly something with the encoding with NSURLSession?

P.S. I've checked to make sure the flags on my compiler for optimization are set to "None".

Any ideas?

crash in XML.swift

Hello there!

I found another source of crashes in updated 3.0.4 version. It is in XML.swift:37.

   init(data: Data) {
        ensureLibXMLErrorHandlingSuppressed()
        
        guard data.count > 0 else { return }
        
        _document = data.withUnsafeBytes { (p: UnsafePointer<Int8>) -> htmlDocPtr in
            return xmlReadMemory(p, Int32(data.count), nil, nil, 0) // <- here
        }
    }

Seems like invalid xml response (for example, when processing browserconfig.xml) causes it.

You can reproduce this crash by downloadAll for URL:https://jex3.netlify.com

I fave fixed it this way:

    init(data: Data)
    {
        ensureLibXMLErrorHandlingSuppressed()
        
        guard data.count > 0 else { return }
        
        var ptr : xmlDocPtr? = nil
        
        data.withUnsafeBytes
        { (p: UnsafePointer<Int8>) in
                
            ptr = xmlReadMemory(p, Int32(data.count), nil, nil, 0)
        }
        
        guard let p = ptr else { return }
        
        _document = p
    }

PS: same issue potentially can occur in HTML.swift

Error: Running Example Project

I am trying to run the example project and get the following error code for the youtube URL:

Failed: The operation couldn’t be completed. (FavIcon.IconError error 2.).

any idea why this happens?
And what does this error code even mean?

Release 3.1.0 not available on CocoaPods

Hi leonbreedt,

First of all, thanks for taking the time to update this repo to Swift 5.
However, I can't find the latest version (3.1.0) on CocoaPods. Could you push this version to the CocoaPods repo?

Best regards,

Robert

Low-Res Icons being loaded for some Pages

Hi! Thanks for this fantastic library.

I have an issue where I use the exact sample code from the readme, but get low-resolution images for some pages:

screenshot 2018-10-31 at 14 51 15

A page where I've seen this is Facebook. Both m.facebook.com and www.facebook.com return icons that are not the highest resolution. The same seems to be happening with www.youtube.com.

Do you have any pointers what I might be doing wrong, or where I could look around to debug this? I'm happy to provide a PR once I find a solution to the issue :)

Does it work for OSX ?

I am creating a Mac OSX App and was wondering if this library can be used in that? Please pardon me if its a dump question. I am new to Apple development.

Also, will it work seamlessly if my current project is in Swift 5?

libxml/xmlversion.h not found

Hi, I am using Carthage to include this lib to my project

when I import FavIcon, there's message show below

include/libxml2/libxml/HTMLparser.h:15:10: 'libxml/xmlversion.h' file not found

Link rel generated by Javascript is not properly evaluated

Some pages are generating url to link rel by javascript, but FavIcon currently cannot evaluate it and as a result icon is not recognized.

Sample webpage: https://www.dcuniverse.com/
Actual link: <link rel="icon" href="{{\'images/favicon.ico\'| buildPath}}" type="image/png">
Expected link: <link rel="icon" href="https://www.dcuniverse.com/builds/892ed368/images/favicon.ico" type="image/png">
Correct href: https://www.dcuniverse.com/builds/892ed368/images/favicon.ico

Must set App Transport Security Allow Arbitrary Loads to Yes

I'm trying to get a favicon like this FavIcon.downloadPreferred("https://theverge.com", width: 128, height: 128). The request always fails with "noIconsDetected" as I get this iOS error:

App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.

Enabling arbitrary loads solves the issue but that can lead to security issues. For some reason the library turns my HTTPS urls into HTTPs. Any idea?

Make sortIcons function public?

Would you consider making the sortIcons function public so it can be accessed outside the library? I'd like to use the equivalent functionality to the downloadPreferred function, but I only want to store the icon URLs and leave actual image loading to another area in the app. If the sortIcons func were available, I could use the scan function to get all the Icons, then sort them by my desired size and finally grab the topmost icon and store that URL.

If I sent in a PR with that change, would you merge it?

Library not loaded: @rpath/FavIcon.framework/FavIcon: "Image not found"

I downloaded this project, build it and dragged the framework across to my project. Then I am trying to build it, and I am getting:

dyld: Library not loaded: @rpath/FavIcon.framework/FavIcon Referenced from: /Users/username/Library/Developer/CoreSimulator/Devices/.... Reason: image not found (lldb)

Runtime Search Path for FavIcon-macOS target

Thanks for the wonderful library. We used FavIcon one of our macOS app and it is working awesome.

Recently we encountered an issue where our app crashes immediately after launch only when an older version of Xcode is installed in the Applications directory on user's Mac. (It works fine when no Xcode has been installed.)

Crash report
Process:               Haste [899]
Path:                  /Applications/Haste.app/Contents/MacOS/Haste
Identifier:            com.plastic-software.Haste
Version:               ???
App Item ID:           1175250324
App External ID:       828388155
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           Haste [899]
User ID:               501

Date/Time:             2018-09-06 16:40:06.070 +0900
OS Version:            Mac OS X 10.11.6 (15G22010)
Report Version:        11
Anonymous UUID:        FF5EE1F3-AFED-30DE-A52F-3C2C7A1FDD6A

Sleep/Wake UUID:       2DB636DE-3D66-49FB-B0C3-AAAED33AC960

Time Awake Since Boot: 2100 seconds
Time Since Wake:       190 seconds

System Integrity Protection: enabled

Crashed Thread:        0

Exception Type:        EXC_BREAKPOINT (SIGTRAP)
Exception Codes:       0x0000000000000002, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Application Specific Information:
dyld: launch, loading dependent libraries

Dyld Error Message:
  Symbol not found: __TMSi
  Referenced from: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftos.dylib
  Expected in: /Applications/Haste.app/Contents/MacOS/../Frameworks/libswiftCore.dylib
 in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftos.dylib

Binary Images:
       0x10c407000 -        0x10c75aff7 +libswiftCore.dylib (4.1.2 - 902.0.54) <F318B448-C59C-3FE4-A2F5-28807B333CDE> /Applications/Haste.app/Contents/Frameworks/libswiftCore.dylib
       0x10ca0b000 -        0x10ca14fff +libswiftCoreData.dylib (4.1.2 - 902.0.54) <CDB72D6F-F272-3028-8033-99D7589452E1> /Applications/Haste.app/Contents/Frameworks/libswiftCoreData.dylib
       0x10ca29000 -        0x10ca2cfff +libswiftCoreFoundation.dylib (4.1.2 - 902.0.54) <B4751639-D527-3851-B923-10FE0A7F7E10> /Applications/Haste.app/Contents/Frameworks/libswiftCoreFoundation.dylib
       0x10ca39000 -        0x10ca4bfff +libswiftCoreGraphics.dylib (4.1.2 - 902.0.54) <A37BDDBC-C0A5-32A1-BF50-104280CD59F9> /Applications/Haste.app/Contents/Frameworks/libswiftCoreGraphics.dylib
       0x10ca8c000 -        0x10ca93ff7 +libswiftDarwin.dylib (4.1.2 - 902.0.54) <F691AB87-664D-3032-8DFC-7B43F153430D> /Applications/Haste.app/Contents/Frameworks/libswiftDarwin.dylib
       0x10caaa000 -        0x10cac4ff7 +libswiftDispatch.dylib (4.1.2 - 902.0.54) <983D3A77-6B82-34EF-A911-85FCD411A20D> /Applications/Haste.app/Contents/Frameworks/libswiftDispatch.dylib
       0x10cafa000 -        0x10cc6eff7 +libswiftFoundation.dylib (4.1.2 - 902.0.54) <3E95BEE7-7BA5-3073-9EB8-FD8BD3FC5C59> /Applications/Haste.app/Contents/Frameworks/libswiftFoundation.dylib
       0x10cdbc000 -        0x10cdbfff7 +libswiftIOKit.dylib (4.1.2 - 902.0.54) <DCCC358D-C25E-3D62-99F4-D30E103FD262> /Applications/Haste.app/Contents/Frameworks/libswiftIOKit.dylib
       0x10cde2000 -        0x10cde8fff +libswiftObjectiveC.dylib (4.1.2 - 902.0.54) <A357C008-2D9C-3F5A-BC78-9A016E1CF3EF> /Applications/Haste.app/Contents/Frameworks/libswiftObjectiveC.dylib
       0x10ce16000 -        0x10ce19fff +libswiftXPC.dylib (4.1.2 - 902.0.54) <7D80DFCA-CAC4-390C-908A-7E620BF8ED20> /Applications/Haste.app/Contents/Frameworks/libswiftXPC.dylib
(Cont.)

And for the following part in the crash report:

Dyld Error Message:
  Symbol not found: __TMSi
  Referenced from: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftos.dylib
  Expected in: /Applications/Haste.app/Contents/MacOS/../Frameworks/libswiftCore.dylib
 in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftos.dylib

We wondered why the app tried to reference the libswiftos.dylib from under "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/" rather than the framework directory under the application's executable path.

After some investigation, we found that the Runtime Search Path (for FavIcon-macOS target) of the FavIcon.xcodeproj is set to "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx", that renders to the aforementioned path. (Presumably the app tried to load the .dylib from there rather than from within the app itself because the .dylib existed in there, but crashed as its version was incompatible when the version of the Xcode was old).

Setting the specified Runtime Search Path to empty seemed to have resolved the issue.
(Some other libraries seems to have it "@executable_path/../Frameworks", others have it empty, I am not sure which should be appropriate - We just had it empty and it seems to be working OK).

Changing a Runtime Search Path before building FavIcon library is tribal, however it would be hard to maintain as we manage the libraries for the project with Carthage.

Would you please consider about changing the Runtime Search Path for FavIcon-macOS target as appropriate? Please let me know what you think. Thanks!

How to use and import in SWIFT4?

I tried to add into my project, but to be honest, I ended up with a bunch of errors, and also it doesn't find these files.
#import "libxml/tree.h"
#import "libxml/xpath.h"
#import "libxml/xpathInternals.h"

How to avoid whole app crashing because of assert https http

I have a large list of urls that I need to preview their favicon.
While scrolling the list some of them are like angel.co, with no http, https.
Some contain www.google.com. Some are forum.site.com

While compiling in debug, the assert in Download.swift gets hit every time some non http urls comes in.
Even if I do "if !contain http -> insert http", still having this issue.

For instance this one "http://forum.tvfreeload.com/ucp.php" causes the trouble.

Console:

po urls
▿ 1 element
  ▿ 0 : data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAy ... rkJggg==
    - _url : data:image/png;base64,iVBO

Maybe you could externalise somehow the final url that needs to be downloaded so we could use our image caching libs, for example, to get and cache the final image?

Crash in HTML.swift:32

Hi, Leon!

First, thank you for this module, it is really helpful.

Now, the issue...

I work on app that allows users to add some bookmarks (URLs), so i use FavIcon to retrieve icons for those URLs.
The app has been approved for Testflight distribution.

And I got several crash reports via Crashlytics recently.

Using FavIcon (3.0.3)

Here is the stack:

Crashed: com.apple.main-thread

0  FavIcon                        0x10320cfc4 specialized HTMLDocument.(init(data : Data) -> HTMLDocument).(closure #1) (HTML.swift:32)
1  FavIcon                        0x10320d900 @callee_owned (@unowned UnsafePointer<Int8>) -> (@unowned UnsafeMutablePointer<_xmlDoc>, @error @owned Error)_xmlDoc (XML.swift)
2  FavIcon                        0x10320ceb8 @callee_owned (@unowned UnsafePointer<Int8>) -> (@unowned UnsafeMutablePointer<_xmlDoc>, @error @owned Error)_xmlDoc (HTML.swift)
3  FavIcon                        0x10320f430 specialized Data.(withUnsafeBytes<A, B> ((UnsafePointer<B>) throws -> A) throws -> A).(closure #1) (XML.swift)
4  FavIcon                        0x10320cf44 partial apply for specialized  (HTML.swift)
5  libswiftFoundation.dylib       0x1039c0c8c (Missing)
6  FavIcon                        0x10320cdb0 specialized HTMLDocument.init(data : Data) -> HTMLDocument (HTML.swift:31)
7  FavIcon                        0x103208608 specialized static FavIcon.(scan(URL, completion : ([Icon]) -> ()) -> ()).(closure #2) (FavIcon.swift:74)
8  FavIcon                        0x10320a738 partial apply for static FavIcon.(scan(URL, completion : ([Icon]) -> ()) -> ()).(closure #1) + 4373980984
9  FavIcon                        0x1031ff458 (downloadURL(URL, method : String, completion : (DownloadResult) -> ()) -> ()).(closure #1) (Download.swift:120)
10 FavIcon                        0x103204fb4 specialized (downloadURLs([URL], method : String, completion : ([DownloadResult]) -> ()) -> ()).(closure #3) (Download.swift:115)
11 FavIcon                        0x10320323c partial apply for (downloadURLs([URL], method : String, completion : ([DownloadResult]) -> ()) -> ()).(closure #3) (Download.swift)
12 FavIcon                        0x103205820 thunk (FavIcon.swift)
13 libdispatch.dylib              0x1d74736c8 _dispatch_call_block_and_release + 24
14 libdispatch.dylib              0x1d7474484 _dispatch_client_callout + 16
15 libdispatch.dylib              0x1d74209ec _dispatch_main_queue_callback_4CF$VARIANT$mp + 1068
16 CoreFoundation                 0x1d79ca1bc __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
17 CoreFoundation                 0x1d79c5084 __CFRunLoopRun + 1964
18 CoreFoundation                 0x1d79c45b8 CFRunLoopRunSpecific + 436
19 GraphicsServices               0x1d9c35584 GSEventRunModal + 100
20 UIKitCore                      0x203fb27ac UIApplicationMain + 212
21 **************                 0x102a66158 main (*****************)
22 libdyld.dylib                  0x1d7484c0c start + 4

So it looks like it crashes in following code:

init(data: Data) {
        ensureLibXMLErrorHandlingSuppressed()
        _document = data.withUnsafeBytes { (p: UnsafePointer<Int8>) -> htmlDocPtr in
            return htmlReadMemory(p, Int32(data.count), nil, nil, 0)
        }
    }

i call it that way:

do
{
     try FavIcon.downloadAll(task, completion:
     { (results : [IconDownloadResult]) in
          ...
     })//downloadAll
     
}
catch
{
      ...
}

but catch block can't handle that exception.

Since the bookmarks considered as private information, i can't ask users about certain urls.

What can you suggest?

Thanks.

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.