gnosygnu / xowa

xowa offline wiki application
Other
377 stars 40 forks source link

Luaj: Do not match end-of-string for frontier patterns (=Module:jdt-translit:284 attempt to index ? (a nil value)) #732

Closed desb42 closed 4 years ago

desb42 commented 4 years ago

Having just rebuilt enwiktionary (2020-05-01), I got three of these errors

The pages are:

суьрх 
syrx
סאורכ 

It happens that Module:jdt-translit has a typo (but this is not the issue here) [the typo is that the table he_to_final exists but there is an attempt to index he_to_finals] This error should not be triggered (but it is)

The lines responsible are at the bottom of the Module starting with

return he_finals(mw.ustring.gsub(export.tr(text, lang, sc) or text, ".", tt_tohe))

he_finals is the actual concern

local function he_finals(text)
    -- Keep in mind RTL issues when viewing the following pattern:
    text = mw.ustring.gsub(text, "([כמנפצ])([^א-ת]-%f[%s־-])", he_finals_replacer)
    return text
end

It seems that somehow the regex is matching (which it should not)

Taking the first page en.wiktionary.org/wiki/суьрх

this can be boiled down to the call export.he('суьрх' , 'jdt' , nil )

gnosygnu commented 4 years ago

Thanks for the detail. Trying to finish up #721. Will work on these a little afterwards. Thanks.

gnosygnu commented 4 years ago

Thanks for the breakdown. Very nice as always.

Agree that the match is happening when it should not. I looked at this a little last night, and couldn't figure it out. Will look at it more later today, as well as the other Luaj Regex issues.

gnosygnu commented 4 years ago

Okay, I think I tracked down the problem. It's in luaj_xowa within this section of code: https://github.com/gnosygnu/luaj_xowa/blob/5dae65ef59d2ff55e735fb9846054bd90b6b7430/src/core/org/luaj/vm2/lib/Match_state.java#L391

Basically, instead of src_pos < src.Len_in_data() && it should be src_pos >= src.Len_in_data() ||

Let me think about this some more and put in a commit tomorrow.

Thanks.

gnosygnu commented 4 years ago

Fixed with the commit above. Added a little more documentation as well as a unit-test

Thanks as always for the report!

gnosygnu commented 4 years ago

Actually, failed to run test. :( Moving back to in progress

gnosygnu commented 4 years ago

Okay. Resolved issue. Similar to previous fix, but found deleted code. Tests passed. :)