Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

panic: runtime error: index out of range [-1] #4

Closed
dima2306 opened this issue Mar 17, 2023 · 5 comments
Closed

panic: runtime error: index out of range [-1] #4

dima2306 opened this issue Mar 17, 2023 · 5 comments

Comments

@dima2306
Copy link

Hello, the project I wanted to try this tool on is a very old Laravel 5.2

After running ./vendor/bin/hsa check I get the error:

Config file used successfully                                                                                                                                                                                                                                                                                        ─╯
panic: runtime error: index out of range [-1]

goroutine 1 [running]:
github.com/MaestroError/html-strings-affixer/parsehtml.(*Parsehtml).removeParseSuffix(0xc000109e68, {0x0, 0x0})
        /home/maestroerror/Desktop/html-strings-affixer/parsehtml/parsehtml.go:361 +0x92
github.com/MaestroError/html-strings-affixer/parsehtml.(*Parsehtml).parseContent(0xc000109e68, {0x533912, 0x4})
        /home/maestroerror/Desktop/html-strings-affixer/parsehtml/parsehtml.go:323 +0xd8
github.com/MaestroError/html-strings-affixer/parsehtml.(*Parsehtml).ExtractTextCC(0xc000109e68)
        /home/maestroerror/Desktop/html-strings-affixer/parsehtml/parsehtml.go:151 +0x8b
github.com/MaestroError/html-strings-affixer/parsehtml.(*Parsehtml).ParseFile(0xc000109e68, {0xc000114090?, _}, {{0xc0000be3d0, 0xf}, {0xc0000b8140, 0x1, 0x4}, {0x654630, 0x0, ...}, ...})
        /home/maestroerror/Desktop/html-strings-affixer/parsehtml/parsehtml.go:51 +0xb4
github.com/MaestroError/html-strings-affixer/app.runCheckCommand()
        /home/maestroerror/Desktop/html-strings-affixer/app/app.go:236 +0x145
github.com/MaestroError/html-strings-affixer/app.Start()
        /home/maestroerror/Desktop/html-strings-affixer/app/app.go:64 +0x69
main.main()
        /home/maestroerror/Desktop/html-strings-affixer/main.go:19 +0x25

Can this error occur if some blade files can have corrupted HTML structure or HTML fragments? I mean some files are "partial" and imported.

@MaestroError
Copy link
Owner

Hi @dima2306 ! Thanks for creating an issue. Not sure, but yes could be, because we have a problem with ExtractTextCC method, which is the "closing tag <-> closing tag" text extraction function. Please, send me your blade files (if you can), and I will find out how we can fix it 👍

@dima2306
Copy link
Author

Hi @MaestroError. I think it will be very informative if this package can show on which file(s) it got stuck.
I've noticed that it translated 98 blade files. When writing my previous message I didn't look at the project's files.

@dima2306
Copy link
Author

One file where I got the error is this:

<section class="refereal_" style="margin-top: 0;">
        <br>
        <div id="titletext">
          Poleć koledze -<br><br>i zbierajcie razem punkty!
        </div>
        <div id="timeline">
            <div class="dot" id="one">
                <span></span>
                <date>pierwszy krok</date>
            </div>
            <div class="dot" id="two">
                <span></span>
                <date>Drugi krok</date>
            </div>
            <div class="dot" id="three">
                <span></span>
                <date>Trzeci krok</date>
            </div>
            <div class="dot" id="four">
                <span></span>
                <date>Czwarty krok</date>
            </div>
            <div class="inside"></div>
        </div>

        <div id="titletext2">
            <center>...</center>
        </div>

        <article class='modal one'>
            <date>Użyj przycisku zaproszenia poniżej</date>
            <h2>Zaproś kolegę</h2>
            <p>
            <center><br>Wpisz <b>adres e-mail</b> lub <b>numer telefonu</b> zaproszonych współpracowników
              nauczyciel będzie mógł połączyć się z systemem. W ten sposób nowy profil zostanie natychmiast dodany
              społeczność nauczycieli KINGS, dzięki czemu nauczyciel nie będzie musiał czekać na administrację
              of KINGS, aby ją przejrzeć i zatwierdzić..<br></center>
            </p>
        </article>

        <article class='modal two'>
            <date>W razie potrzeby wyjaśnij współpracownikowi, jak się zarejestrować</date>
            <h2>Twój kolega się rejestruje</h2>
            <p>
            <center><br>Zaproszony nauczyciel z kodem polecającym może wejść na stronę KINGS (www.kingsolympiad.com)
              i wypełnij formularz rejestracyjny nauczyciela w ciągu kilku minut. Kiedy rejestrujesz nowego nauczyciela,
              musisz wprowadzić podany przez siebie kod polecenia, aby zarówno Ty, jak i Twój współpracownik mogli to zrobić
              korzystać z KRÓLÓW.<br></center>
            </p>

        </article>

        <article class='modal three'>
            <date>Uczestników Olimpiady dodaje się poprzez profil nauczyciela</date>
            <h2>Zarejestrowani uczestnicy</h2>
            <p>
            <center><br>Nauczyciel, który zarejestruje się za pomocą podanego kodu polecającego, będzie mógł się zarejestrować
              studentów na swoim profilu. Zarejestrowani studenci od razu otrzymują możliwość bezpłatnego udziału
              faza kwalifikacyjna. <br></center>
            </p>
        </article>

        <article class='modal four'>
            <date>Korzyści dla uczniów i nauczycieli!</date>
            <h2>Dodatkowe punkty!</h2>
            <p class="text-center"><br>Jeśli uczniowie zarejestrowani przez nowego nauczyciela napiszą co najmniej 10 testów do etapu kwalifikacyjnego Olimpiady, otrzymasz 40 punktów aktywności. Te dodatkowe punkty zostaną dodane do Twojego profilu na koniec okresu i będziesz mógł je wymienić na wybrane przez siebie nagrody!<br></p>
        </article>
        <div style="padding-top:0; margin-bottom: 0" class="container">
            <div class="row">
                <div class="col-12 d-flex flex-column align-items-center">
                    <div>@if($pageText) {!! $pageText->content !!} @endif</div>
                </div>
                <form id="sendViaEmailForm">
                    <input style="display: none" type="Email" placeholder="E-mail" name="email" class="form-control">
                    <button id="sendViaEmailBtn">Zaproś kolegę przez e-mail</button>
                </form>

                <form id="sendViaPhoneForm">
                    <input style="display: none" type="text" name="phone" placeholder="Telefon. nie." class="form-control">
                    <button id="sendViaPhoneBtn"> Zaproś kolegę przez telefon</button>
                </form>
            </div>
        </div>
    </section>

There are some deprecated and unknown tags like <center> and <date>.

Output:

Config file used successfully                                                                                                                                                                                                                                                                                        ─╯
Confirm: You have uncommitted changes. Recommended to commit or stash them first. Continue anyway? y/n [yes]: 
y
- You have uncommitted changes, you can use -force parameter in cli or set 'force' to true in config file to avoid confirmation)
panic: runtime error: index out of range [-1]

goroutine 1 [running]:
github.com/MaestroError/html-strings-affixer/parsehtml.(*Parsehtml).removeParseSuffix(0xc000287e68, {0x0, 0x0})
        /home/maestroerror/Desktop/html-strings-affixer/parsehtml/parsehtml.go:361 +0x92
github.com/MaestroError/html-strings-affixer/parsehtml.(*Parsehtml).parseContent(0xc000287e68, {0x533912, 0x4})
        /home/maestroerror/Desktop/html-strings-affixer/parsehtml/parsehtml.go:323 +0xd8
github.com/MaestroError/html-strings-affixer/parsehtml.(*Parsehtml).ExtractTextCO(0xc000287e68)
        /home/maestroerror/Desktop/html-strings-affixer/parsehtml/parsehtml.go:162 +0x9b
github.com/MaestroError/html-strings-affixer/parsehtml.(*Parsehtml).ParseFile(0xc000287e68, {0xc00001e2d0?, _}, {{0xc000014340, 0x1b}, {0xc000112140, 0x1, 0x4}, {0xc000112180, 0x2, ...}, ...})
        /home/maestroerror/Desktop/html-strings-affixer/parsehtml/parsehtml.go:52 +0xc5
github.com/MaestroError/html-strings-affixer/app.runReplaceCommand()
        /home/maestroerror/Desktop/html-strings-affixer/app/app.go:180 +0x325
github.com/MaestroError/html-strings-affixer/app.Start()
        /home/maestroerror/Desktop/html-strings-affixer/app/app.go:61 +0x96
main.main()
        /home/maestroerror/Desktop/html-strings-affixer/main.go:19 +0x25

@MaestroError
Copy link
Owner

@dima2306 Thank you! Already added in to do for the next release 👍

@MaestroError
Copy link
Owner

Fixed ✔️ Closing the issue, feel free to open new one 👍

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants